Created
August 23, 2012 22:36
-
-
Save betovelandia/3442855 to your computer and use it in GitHub Desktop.
Order List Alphabetically
This file contains hidden or 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 orderSelect($element) { | |
| var options = $element.find('option'), | |
| n_options = options.length, | |
| temp = [], | |
| parts, | |
| i; | |
| for(i = n_options; i --;) { | |
| temp[i] = options[i].text + "," + options[i].value ; | |
| } | |
| temp.sort(); | |
| for(i = n_options; i --;) { | |
| parts = temp[i].split(','); | |
| options[i].text = parts[0]; | |
| options[i].value = parts[1]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment