Prev: Using a TEA package
Next: Strange embedded proc error
From: Bruce on 22 Sep 2009 08:58 Alexandre Ferrieux wrote: > On Sep 22, 12:28 am, Georgios Petasis <peta...(a)iit.demokritos.gr> > wrote: >> But it would be much more simple if dict had an lsort command of its >> own, with the ability to sort with keys or values :-) > > Sorting on keys is what you get with [-stride 2], though in the > process you lose dict-ness (you shimmer to a list -- which may be OK > in most circumstances). > > Sorting on values implies reverting the dict; so maybe a better > primitive would be [dict revert], but I'm not sure how much a C > implementation would gain over the Tcl version... > no, just use -stride 2 -index 1 Bruce
From: Alexandre Ferrieux on 22 Sep 2009 09:25 On Sep 22, 2:58 pm, Bruce <Bruce_do_not_...(a)example.com> wrote: > Alexandre Ferrieux wrote: > > On Sep 22, 12:28 am, Georgios Petasis <peta...(a)iit.demokritos.gr> > > wrote: > >> But it would be much more simple if dict had an lsort command of its > >> own, with the ability to sort with keys or values :-) > > > Sorting on keys is what you get with [-stride 2], though in the > > process you lose dict-ness (you shimmer to a list -- which may be OK > > in most circumstances). > > > Sorting on values implies reverting the dict; so maybe a better > > primitive would be [dict revert], but I'm not sure how much a C > > implementation would gain over the Tcl version... > > no, just use -stride 2 -index 1 Oh, very nice, thanks ! (The only remaining thing needing dict reversion is getting the lists of keys corresponding to each value. Doable with a simple loop, but not elegant. Or do you have a solution ?) -Alex
From: George Petasis on 22 Sep 2009 09:41 O/H Bruce έγραψε: > Alexandre Ferrieux wrote: >> On Sep 22, 12:28 am, Georgios Petasis <peta...(a)iit.demokritos.gr> >> wrote: >>> But it would be much more simple if dict had an lsort command of its >>> own, with the ability to sort with keys or values :-) >> >> Sorting on keys is what you get with [-stride 2], though in the >> process you lose dict-ness (you shimmer to a list -- which may be OK >> in most circumstances). >> >> Sorting on values implies reverting the dict; so maybe a better >> primitive would be [dict revert], but I'm not sure how much a C >> implementation would gain over the Tcl version... >> > > no, just use -stride 2 -index 1 > > Bruce The -stride option is available only in 8.6... George
From: Bruce on 22 Sep 2009 09:50
George Petasis wrote: > O/H Bruce έγραψε: >> Alexandre Ferrieux wrote: >>> On Sep 22, 12:28 am, Georgios Petasis <peta...(a)iit.demokritos.gr> >>> wrote: >>>> But it would be much more simple if dict had an lsort command of its >>>> own, with the ability to sort with keys or values :-) >>> >>> Sorting on keys is what you get with [-stride 2], though in the >>> process you lose dict-ness (you shimmer to a list -- which may be OK >>> in most circumstances). >>> >>> Sorting on values implies reverting the dict; so maybe a better >>> primitive would be [dict revert], but I'm not sure how much a C >>> implementation would gain over the Tcl version... >>> >> >> no, just use -stride 2 -index 1 >> >> Bruce > > The -stride option is available only in 8.6... > > George I know it doesn't solve your immediate issue, but Alexandre mentioned that once available it handled sort by key, but thought there was more hoops for sort by value - i just was pointing out the you can combine stride with index to get the functionality as well. Bruce |