lib/haveapi/cli/output_formatter.rb in haveapi-client-0.5.0 vs lib/haveapi/cli/output_formatter.rb in haveapi-client-0.5.1
- old
+ new
@@ -173,10 +173,16 @@
if @sort
col_i = @cols.index { |c| c[:name] == @sort }
fail "unknown column '#{@sort}'" unless col_i
@str_objects.sort! do |a, b|
- a[col_i] <=> b[col_i]
+ a_i = a[col_i]
+ b_i = b[col_i]
+
+ next 0 if a_i == @empty && b_i == @empty
+ next -1 if a_i == @empty && b_i != @empty
+ next 1 if a_i != @empty && b_i == @empty
+ a_i <=> b_i
end
end
@str_objects
end