You can use beforeRender to modify each item in list, but not the whole list. From what I knwo the only viable way to do this is to make your own template.
I tried that but when I insert a function in the index.php I get a fatal error...I would need to use a recursive function but can't do it. Any idea, suggestion?
You can manage the ordering of items in your search type. If the tools are not enough to build the right query, you may consider purchasing some advanced plugin e.g. Search Query.
If you still need to perform some reordering after you got items from the database, you can do it in a custom list template, as Klas suggested above. You'll find the items in the array $items and it is up to you what you will do with that.