Optional parameters: Difference between revisions

m
→‎{{header|Sidef}}: added an example how to provide a custom method for sorting
m (Added Sidef language)
m (→‎{{header|Sidef}}: added an example how to provide a custom method for sorting)
Line 1,779:
{{out}}
<pre>[["Ottowa", "Canada"], ["Mexico City", "Mexico"], ["Washington", "USA"]]</pre>
 
You can also create and provide a custom method for sorting to ''ordering'':
<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').dump;</lang>
{{out}}
<pre>[["Washington", "USA"], ["Ottowa", "Canada"], ["Mexico City", "Mexico"]]</pre>
 
=={{header|Slate}}==
2,747

edits