Optional parameters: Difference between revisions
m
→{{header|Sidef}}: modified the code to work with Sidef 2.30
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
|||
Line 1,898:
];
say table_sort(table, column: 1)
{{out}}
<pre>[["Ottowa", "Canada"], ["Mexico City", "Mexico"], ["Washington", "USA"]]</pre>
<lang ruby>class String {
method my_sort(arg) {
(self.len <=> arg.len) ->
|| (self.lc <=> arg.lc) ->
|| (self <=> arg)
}
}
say table_sort(table, column: 1, ordering: 'my_sort')
{{out}}
<pre>[["Washington", "USA"], ["Ottowa", "Canada"], ["Mexico City", "Mexico"]]</pre>
|