Largest int from concatenated ints: Difference between revisions

→‎{{header|jq}}: give second algorithm using a custom sort
(jq)
(→‎{{header|jq}}: give second algorithm using a custom sort)
Line 544:
=={{header|jq}}==
{{Works with|jq|1.4}}
==== Padding ====
''For jq versions greater than 1.4, it may be necessary to change "sort_by" to "sort".''
 
The following uses the padding technique.
<lang jq>def largest_int:
 
Line 565 ⟶ 564:
998764543431
6054854654
 
====Custom Sort====
The following uses [[Sort_using_a_custom_comparator#jq| quicksort/1]]:
<lang jq>def largest_int:
map(tostring)
| quicksort( .[0] + .[1] < .[1] + .[0] )
| reverse | join("") ;</lang>
 
=={{header|Lua}}==
2,497

edits