Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Created March 9, 2012 08:34
Show Gist options
  • Save alvinsj/2005665 to your computer and use it in GitHub Desktop.
Save alvinsj/2005665 to your computer and use it in GitHub Desktop.
[jquery] sort list items by numbers (e.g.data-age)
$.sort_by_numbers = (ulClass, number) ->
$("ul.#{ulClass} li").sort (a, b) ->
if parseInt($(a).data("#{number}")) > parseInt($(b).data("#{number}")) then 1 else -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment