Created
November 16, 2015 04:41
-
-
Save Rijen/4acfabdb00f91198c032 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
var options = $('select#routeNumber option'); | |
var arr = options.map(function (_, o) { | |
return {t: $(o).text(), v: o.value, r:$(o).prop('-data-role'),n:$(o).prop('-data-name')}; | |
}).get(); | |
arr.sort(function (o1, o2) { | |
return parseInt(o1.t) > parseInt(o2.t) ? 1 : parseInt(o1.t) < parseInt(o2.t) ? -1 : 0; | |
}); | |
options.each(function (i, o) { | |
o.value = arr[i].v; | |
$(o).text(arr[i].t); | |
$(o).prop('-data-role',arr[i].r); | |
$(o).prop('-data-name',arr[i].n); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment