From e2f8d56152889007ecdc2a8d62ffae3c04fbdb50 Mon Sep 17 00:00:00 2001 From: Marc Roberts Date: Fri, 12 Jul 2013 10:49:03 +0100 Subject: [PATCH] fix V8 unstable sort 'bug' --- jquery.select-to-autocomplete.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jquery.select-to-autocomplete.js b/jquery.select-to-autocomplete.js index 9bbf06a..09d19dc 100755 --- a/jquery.select-to-autocomplete.js +++ b/jquery.select-to-autocomplete.js @@ -250,7 +250,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 ); },