Created
May 4, 2021 16:19
-
-
Save j3ck/a9da7a3684b59cecfcf560ca76a6d9ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacBook-Pro-Eugene:parimatch_rus-back j3ck$ ruby -v | |
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin18] | |
MacBook-Pro-Eugene:back j3ck$ irb | |
2.3.5 :001 > order = [] | |
=> [] | |
2.3.5 :002 > columns = [ | |
2.3.5 :003 > {:name=>:id}, | |
2.3.5 :004 > {:name=>:em}, | |
2.3.5 :005 > {:name=>:na}, | |
2.3.5 :006 > {:name=>:si}, | |
2.3.5 :007 > {:name=>:af}, | |
2.3.5 :008 > {:name=>:re}, | |
2.3.5 :009 > {:name=>:de}, | |
2.3.5 :010 > {:name=>:aa} | |
2.3.5 :011?> ] | |
=> [{:name=>:id}, {:name=>:em}, {:name=>:na}, {:name=>:si}, {:name=>:af}, {:name=>:re}, {:name=>:de}, {:name=>:aa}] | |
2.3.5 :012 > columns.sort_by { |e| order.index(e[:name].to_s).to_i } | |
=> [{:name=>:aa}, {:name=>:em}, {:name=>:na}, {:name=>:si}, {:name=>:af}, {:name=>:re}, {:name=>:de}, {:name=>:id}] | |
2.3.5 :013 > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@aws-back3:~$ ruby -v | |
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux] | |
ubuntu@aws-back3:~$ irb | |
2.3.5 :001 > order = [] | |
=> [] | |
2.3.5 :002 > columns = [ | |
2.3.5 :003 > {:name=>:id}, | |
2.3.5 :004 > {:name=>:em}, | |
2.3.5 :005 > {:name=>:na}, | |
2.3.5 :006 > {:name=>:si}, | |
2.3.5 :007 > {:name=>:af}, | |
2.3.5 :008 > {:name=>:re}, | |
2.3.5 :009 > {:name=>:de}, | |
2.3.5 :010 > {:name=>:aa} | |
2.3.5 :011?> ] | |
=> [{:name=>:id}, {:name=>:em}, {:name=>:na}, {:name=>:si}, {:name=>:af}, {:name=>:re}, {:name=>:de}, {:name=>:aa}] | |
2.3.5 :012 > columns.sort_by { |e| order.index(e[:name].to_s).to_i } | |
=> [{:name=>:id}, {:name=>:em}, {:name=>:na}, {:name=>:si}, {:name=>:af}, {:name=>:re}, {:name=>:de}, {:name=>:aa}] | |
2.3.5 :013 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment