Guest User

Untitled

a guest
Sep 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. sort = (objs, attrs) ->
  2. dojo.map(
  3. (dojo.map objs, (obj) ->
  4. arr = [obj]
  5. dojo.forEach attrs, (attr) ->
  6. arr.push obj.get(attr)
  7. arr
  8. ).sort(
  9. (attrsA, attrsB) ->
  10. i = 1
  11. while i < attrs.length
  12. [a, b] = [attrsA[i], attrsB[i]]
  13.  
  14. #
  15. # This is where CS has nothing on JS
  16. # OMFG isn't this ugly and wasteful
  17. #
  18.  
  19. if a is not b
  20. if attrs[i][1] == "asc"
  21. if a > b
  22. return 1
  23. else
  24. return -1
  25. else
  26. if a > b
  27. return -1
  28. else
  29. return 1
  30. i++
  31. return 0
  32. ), (arr) ->
  33. arr[0]
  34. )
Add Comment
Please, Sign In to add comment