I have an array of hashes:
a=[{ \'foo\'=>0,\'bar\'=>1 },
{ \'foo\'=>0,\'bar\'=>2 },
... ]
I want to sort the array first
This error appeares when you have unstable keys and trying to sort by them. Example:
[{'foo'=>99,'bar'=>1},{'foo'=>0,'bar'=>2, 'qwe' => 7}]
a.sort_by{|v| v['qwe']}
ArgumentError: comparison of NilClass with 7 failed
Try to do
a.sort_by{|v| [v['qwe']].select{|k| not k.nil?}}
But it doesnt work for me in
[v['index'],v['count'],v['digit'],v['value']]
where digit is unstable