Skip to content

Commit

Permalink
Merge pull request #56 from neutroncreations/master
Browse files Browse the repository at this point in the history
workaround for V8's 'broken' sorting algorithm
  • Loading branch information
jamieholst committed Aug 12, 2014
2 parents 6f067f6 + e2f8d56 commit 876e00b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jquery.select-to-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ THE SOFTWARE.
source: function( request, response ) {
var filtered_options = filter_options( request.term );
if ( context.settings['relevancy-sorting'] ) {
filtered_options = filtered_options.sort( function( a, b ) { return b['relevancy-score'] - a['relevancy-score']; } );
filtered_options = filtered_options.sort( function( a, b ) {
if (b['relevancy-score'] == a['relevancy-score']) {
return b['label'] < a['label'] ? 1 : -1;
} else {
return b['relevancy-score'] - a['relevancy-score'];
}
} );
}
response( filtered_options );
},
Expand Down

0 comments on commit 876e00b

Please sign in to comment.