I’m doing a small script to add functionality to the facebook find friends page: basically order the suggested friends by mutual friends.
The code can be found here: http://pastebin.com/x6Ss326A
I’ve tested the script modularly, so I know the paths, sorting function are ok. I’ve used the same technique to sort items in a odered list with simple text, successfully. The problem is in the behaviour of the sorting method, but I cant figure out what’s wrong.
Any suggestions?
The compare function used by sort has to return either a negative number, zero or a positive number, depending on how the arguments should be sorted – not just
trueorfalse. See the MDN entry on sort for reference.The simplest fix for your problem would be to change the return statement of your
sortFriendfunction to