Last active
August 29, 2015 14:09
-
-
Save estruyf/37716172783d40f11ebe to your computer and use it in GitHub Desktop.
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
/* Long Version */ | |
$(".list li").sort(asc_sort).appendTo('.list'); | |
// ascending sort | |
function asc_sort(a, b){ | |
return ($(b).text().toUpperCase()) < ($(a).text().toUpperCase()) ? 1 : -1; | |
} | |
// descending sort | |
function desc_sort(a, b){ | |
return ($(b).text().toUpperCase()) > ($(a).text().toUpperCase()) ? 1 : -1; | |
} | |
/* Short Version */ | |
$(".list li").sort(function(a, b){ | |
return ($(b).text().toUpperCase()) < ($(a).text().toUpperCase()) ? 1 : -1; | |
}).appendTo('.list'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment