sort_stability.sf 242 B

1234567891011121314151617
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Sort_stability
  4. #
  5. var table = [
  6. <UK London>,
  7. <US New\ York>,
  8. <US Birmingham>,
  9. <UK Birmingham>,
  10. ];
  11.  
  12. table.sort {|a,b| a[0] <=> b[0]}.each { |col|
  13. say "#{col[0]} #{col[1]}"
  14. }