The same output of your quoted "program" \:~ _10 1 10 20 _30 15 25 30 0
30 25 20 15 10 1 0 _10 _30 I may have misunderstood your original question, based on subject line. You appear to want to sort card hands. You would want to encode cards as integers, where 2-A maps to 0-13. It is a good J datastructure if you wanted suits to represent it as a "handsize" by 2 shaped table, and 3 dimensional J data would store multiple items of hands. > 2AAAA is greater than A2222> 23452 is lesser than 23453 from a lexicographical sort perspective, (0 12 12 12 12) ([ -: {.@:(\:~)@:,:) 12 0 0 0 0 0 NB. 2AAAA is greater than A2222 ... is false from a descending lexographical sort perspective. What it appears your desired verb to be is to assess the value/rank of poker hands. The scoring function for poker hands can/is be monadic. compareV =: (>&) NB. adverb that will compare 2 scoring functions applied to each dyadic argument. pokerhandscoringfunction compareV On Thursday, December 21, 2023 at 10:17:41 a.m. EST, 'Viktor Grigorov' via Programming <programm...@jsoftware.com> wrote: Maybe a table, summation and a sort using that: (/: ([:+/(>/]))) _10 1 10 20 _30 15 25 30 0 Can't imagine that being efficient, but it's better than nothing. The verb I'd defined can't deal with rank 2 nouns anyways. Dec 21, 2023, 14:21 by programm...@jsoftware.com: > Not quite though. Had I 5 hands, that'd be !4 booleans. > > > Dec 21, 2023, 14:11 by programm...@jsoftware.com: > >> >> 1 0 0 1 0 /:~ i.5 >> >> 1 2 4 0 3 >> >> >> On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via >>Programming <programm...@jsoftware.com> wrote: >> >> Hey, >> >> Is there an easy way to sort an array with verb returning either 0 or 1, >> like the comparison primitives? >> >> The verb that I'd in mind relates to the 2023's advent of code's day 7: >> given two equal length hands, which one has the first high card. Which one >> can write as: >> >> 'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) >> 'KJ2KA' >> 0 NB. here meaning left is not greater right >> >> Cheers, >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm