sort_using_a_custom_comparator.sf 252 B

123456789101112
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Sort_using_a_custom_comparator
  4. #
  5. func mycmp(a, b) { (b.len <=> a.len) || (a.lc <=> b.lc) };
  6. var strings = %w(Here are some sample strings to be sorted);
  7. var sorted = strings.sort(mycmp);
  8. say sorted;