Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sort = (objs, attrs) ->
- dojo.map(
- (dojo.map objs, (obj) ->
- arr = [obj]
- dojo.forEach attrs, (attr) ->
- arr.push obj.get(attr)
- arr
- ).sort(
- (attrsA, attrsB) ->
- i = 1
- while i < attrs.length
- [a, b] = [attrsA[i], attrsB[i]]
- #
- # This is where CS has nothing on JS
- # OMFG isn't this ugly and wasteful
- #
- if a is not b
- if attrs[i][1] == "asc"
- if a > b
- return 1
- else
- return -1
- else
- if a > b
- return -1
- else
- return 1
- i++
- return 0
- ), (arr) ->
- arr[0]
- )
Add Comment
Please, Sign In to add comment