added function sortresults

Maybe this will become handy for someone else than just me.