Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 29, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mistyrinth/666cfd9b7c9fc0f0a8f3c6347ada4fe3 to your computer and use it in GitHub Desktop.
Save mistyrinth/666cfd9b7c9fc0f0a8f3c6347ada4fe3 to your computer and use it in GitHub Desktop.
array = [1, 3, 7, 2, 4, 10, 8]
puts "元の配列は #{array} です"
# 逆順に並び替え
newarray1 = array.reverse
puts "逆順に並び替えると #{newarray1} です"
# ソート
newarray2 = array.sort
puts "ソートすると #{newarray2} です"
# 配列を行列に並べ替え
ary = [[1, 2], [3, 4], [5, 6]]
puts "元の配列は #{ary} です"
newary = ary.transpose
puts "行と列を入れ替えると #{newary} です"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment