This is a very basic question but I’m having a bit of trouble understanding Rubys hash sort method.
Basically whats happening is I’m receiving a cannot convert string to integer so my first guess is I’m sorting the array by a string (which is actually a number). The array contains hashes and I’m trying to sort it by one of the hashes values that I’ve identified with a key.
Heres how I’m sorting my array:
@receivedArray =(params[:respElementDatas])
puts @receivedArray.class #Its definitely an array
@sortedArray = @receivedArray.sort_by{|ed| ed["element_type_id"]}
The error I’m getting is can’t convert String into Integer on the sort line.
Naturally I assumed that
Just a quick question.
Am i right in saying that ‘ed’ is an object that is stored in the array and I’m referencing it correctly? Also any pointers on how to fix it?
Your
@receivedArrayis an array of arrays or has at least one array in it. For example: