RosettaCodeData/Task/Ordered-words/Jq/ordered-words.jq
2023-07-01 13:44:08 -04:00

14 lines
321 B
Text

def is_sorted:
if length <= 1 then true
else .[0] <= .[1] and (.[1:] | is_sorted)
end;
def longest_ordered_words:
# avoid string manipulation:
def is_ordered: explode | is_sorted;
map(select(is_ordered))
| (map(length)|max) as $max
| map( select(length == $max) );
split("\n") | longest_ordered_words