class JMESPath::Nodes::SortFunction
Public Instance Methods
call(args)
click to toggle source
# File lib/jmespath/nodes/function.rb, line 392 def call(args) if args.count == 1 value = args.first if Array === value value.sort do |a, b| a_type = get_type(a) b_type = get_type(b) if (a_type == STRING_TYPE || a_type == NUMBER_TYPE) && a_type == b_type a <=> b else raise Errors::InvalidTypeError, "function sort() expects values to be an array of numbers or integers" end end else raise Errors::InvalidTypeError, "function sort() expects values to be an array of numbers or integers" end else raise Errors::InvalidArityError, "function sort() expects one argument" end end