def call(args)
if args.count == 1
value = args.first
if value.respond_to?(:to_ary)
value = value.to_ary
array_type = get_type(value[0])
if array_type == STRING_TYPE || array_type == NUMBER_TYPE || value.empty?
n = 0
value.sort_by do |v|
value_type = get_type(v)
if value_type != array_type
msg = 'function sort() expects values to be an array of only numbers, or only integers'
return maybe_raise Errors::InvalidTypeError, msg
end
n += 1
[v, n]
end
else
return maybe_raise Errors::InvalidTypeError, 'function sort() expects values to be an array of numbers or integers'
end
else
return maybe_raise Errors::InvalidTypeError, 'function sort() expects values to be an array of numbers or integers'
end
else
return maybe_raise Errors::InvalidArityError, 'function sort() expects one argument'
end
end