[Jprogramming] Sorting on two keys

'Pascal Jasmin' via Programming programming at jsoftware.com
Sat Jan 19 16:51:33 UTC 2019


if one of the columns is numeric, then negating it will sort the right way.

(\: 1 ,/@(+`-\"1) ]) 5 2$7 4 8 2 8 4 7 2 8 3




________________________________
From: Jimmy Gauvin <jimmy.gauvin at gmail.com>
To: programming at jsoftware.com 
Sent: Saturday, January 19, 2019 11:18 AM
Subject: [Jprogramming] Sorting on two keys



Hi,


I need to sort on two keys, one descending the other asscending.

(J takes care were ascending or descending


Is there a better way to solve this ?


   ]t=:5 2$7 4 8 2 8 4 7 2 8 3

7 4

8 2

8 4

7 2

8 3

   ]tt=: t {~ /:1{"1 t

8 2

7 2

8 3

7 4

8 4

   ]tt {~ \:0{"1 tt

8 2

8 3

8 4

7 2

7 4


Thanks,


Jimmy

----------------------------------------------------------------------

For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list