array sorting, function currying