fix a bug concerning the search function (sorting in wrong order)