My sort function is clearly not working, I am trying to sort ALL_VIEWS
by @permalink.length
:
ALL_VIEWS.sort_by {|view| view.permalink.length}
ALL_VIEWS[0..4].each do |view|
puts view.inspect
puts view.permalink.length
end
this produces:
#<View:0x1014da7b8 @permalink="xxxx">
4
#<View:0x1014da790 @permalink="yyyyy">
5
#<View:0x1014da718 @permalink="zzz">
3
#<View:0x1014da6a0 @permalink="aaaaaaa">
7
#<View:0x1014da628 @permalink="b">
1
I am expecting the following result:
#<View:0x1014da628 @permalink="b">
1
#<View:0x1014da718 @permalink="zzz">
3
#<View:0x1014da7b8 @permalink="xxxx">
4
#<View:0x1014da790 @permalink="yyyyy">
5
#<View:0x1014da6a0 @permalink="aaaaaaa">
7