I have an array of hashes which look like:
ward = {id: id, name: record["Externalization"], mnemonic: record["Mnemonic"],
seqno: record["SeqNo"]}
All fields are strings.
Now I want to sort them first on seqno and then on name. seqno can be nil (if seqno is nil, then this ward must come after the ones having a seqno).
What I have so far is:
wardList.sort! do |a,b|
return (a[:name] <=> b[:name]) if (a[:seqno].nil? && b[:seqno].nil?)
return -1 if a[:seqno].nil?
return 1 if b[:seqno].nil?
(a[:seqno] <=> b[:seqno]).nonzero? ||
(a[:name] <=> b[:name])
end
But this gives me the error: can't convert Symbol into Integer