The sort function is given a function from suggestion item to string, as well as the original search string. It is also given two suggestion items, and it should return -1, 0, or 1, similar to most array order-by functions.

The default sort function prefers suggestion strings with earlier occurences of the search string. If the occurence of the search string is equal, the suggestions are sorted alphabetically.