Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created January 19, 2014 08:04
Show Gist options
  • Select an option

  • Save cocodrips/8501820 to your computer and use it in GitHub Desktop.

Select an option

Save cocodrips/8501820 to your computer and use it in GitHub Desktop.
javascript 連想配列をvalueの値でソートする
sortByValue: (data)->
z = []
for k,v of data
z.push([v, k])
z.sort((a, b)->
if a[0] < b[0]
return -1
if a[0] > b[0]
return 1
return 0
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment