Karim BELABAS on Sun, 15 Jun 2003 19:18:11 +0200 (MEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Sorting multi-dimensional vectors


On Sun, 15 Jun 2003, Bill Allombert wrote:
> On Sun, Jun 15, 2003 at 05:47:16PM +0100, Jon Perry wrote:
> > I wish to sort a vector, e.g.
> >
> > [[1,2],[2,3],[1,3]]
> >
> > All the inner vectors are the same length, and the order returned should be;
> >
> > [[1,2],[1,3],[2,3]]
> ? vecsort([[1,2],[2,3],[1,3]],2)
> %1 = [[1, 2], [1, 3], [2, 3]]

Replace (,2) by (,/*empty*/,2)

Your example sorts according to second component of each entry [ happens to
be correct on this example, but... ].

Cheers,

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://www.parigp-home.de/  [PARI/GP]