Sort using a custom comparator: Difference between revisions
Content added Content deleted
m (Added output) |
(Added Quackery.) |
||
Line 3,111: | Line 3,111: | ||
print sorted(strings, cmp=mycmp)</lang> |
print sorted(strings, cmp=mycmp)</lang> |
||
=={{header|Quackery}}== |
|||
<lang Quackery> [ $ "" swap |
|||
witheach |
|||
[ upper join ] ] is upper$ ( $ --> ) |
|||
[ over size over size |
|||
2dup = iff |
|||
[ 2drop upper$ |
|||
swap upper$ $< ] |
|||
else |
|||
[ 2swap 2drop < ] ] is comparator ( $ $ -- b ) |
|||
$ ‘here are Some sample strings to be sorted’ |
|||
nest$ sortwith comparator |
|||
witheach [ echo$ sp ] |
|||
cr cr |
|||
$ "sharna pax and hed on a poal when the ardship of Cambry come out of his hoal" |
|||
nest$ sortwith comparator |
|||
witheach [ echo$ sp ]</lang> |
|||
{{out}} |
|||
<pre>strings sample sorted here Some are be to |
|||
ardship Cambry sharna come hoal poal when and hed his out pax the of of on a </pre> |
|||
=={{header|R}}== |
=={{header|R}}== |