def sort_pipe(object, sort)
      sort_lambda = lambda {}
      if object[0].is_a?(Hash)
        if sort.to_s[/^\d+$/]
          sort = sort.to_i
        elsif object[0].keys.all? {|e| e.is_a?(Symbol) }
          sort = sort.to_sym
        end
        sort_lambda = untouched_sort?(object.map {|e| e[sort] }) ? lambda {|e| e[sort] } : lambda {|e| e[sort].to_s }
      else
        sort_lambda = untouched_sort?(object.map {|e| e.send(sort) }) ? lambda {|e| e.send(sort) || ''} :
          lambda {|e| e.send(sort).to_s }
      end
      object.sort_by &sort_lambda
    rescue NoMethodError, ArgumentError
      $stderr.puts "Sort failed with nonexistant method '#{sort}'"
    end
def sort_pipe(object, sort)
      sort_lambda = lambda {}
      if object[0].is_a?(Hash)
        if sort.to_s[/^\d+$/]
          sort = sort.to_i
        elsif object[0].keys.all? {|e| e.is_a?(Symbol) }
          sort = sort.to_sym
        end
        sort_lambda = untouched_sort?(object.map {|e| e[sort] }) ? lambda {|e| e[sort] } : lambda {|e| e[sort].to_s }
      else
        sort_lambda = untouched_sort?(object.map {|e| e.send(sort) }) ? lambda {|e| e.send(sort) || ''} :
          lambda {|e| e.send(sort).to_s }
      end
      object.sort_by &sort_lambda
    rescue NoMethodError, ArgumentError
      $stderr.puts "Sort failed with nonexistant method '#{sort}'"
    end
Sorts an array of objects or hashes using a sort field. Sort is reversed with reverse_sort set to true.