Your first comparator looks like that, yes, but your second "sort by suit order" comparator looks nothing like that, and doesn't even return an integer. Remember that you must return 0 if the items are equal. Also, sorting twice doesn't work unless the sort is stable, and JavaScript's Array.sort() is not stable.