Created
December 31, 2017 06:08
-
-
Save jindrichsirucek/04ba2649b3fdc5dc5a44d8ccc87e043a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortUlozenkaSelect() | |
{ | |
function localeCompareSupportsLocales() { | |
try { | |
'foo'.localeCompare('bar', 'i'); | |
} catch (e) { | |
return e.name === 'RangeError'; | |
} | |
return false; | |
} | |
var localParamSupport = localeCompareSupportsLocales(); | |
var options = $("select[name='specify_3'] option").not(':first'); // Collect options | |
options.detach().sort(function(a,b) { // Detach from select, then Sort | |
var at = $(a).text(); | |
var bt = $(b).text(); | |
return localParamSupport ? at.localeCompare(bt,"cs"): at.localeCompare(bt); | |
}); | |
options.appendTo("select[name='specify_3']"); | |
} | |
sortUlozenkaSelect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment