UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

20 lines (14 loc) 452 B
var sort = require('./sort'); var makeIterator = require('../function/makeIterator_'); /* * Sort array by the result of the callback */ function sortBy(arr, callback, context){ callback = makeIterator(callback, context); return sort(arr, function(a, b) { a = callback(a); b = callback(b); return (a < b) ? -1 : ((a > b) ? 1 : 0); }); } module.exports = sortBy;