[Numpy-discussion] unique() should return a sorted array

Alan G Isaac aisaac at american.edu
Tue Jul 11 10:47:27 CDT 2006

On Tue, 11 Jul 2006, Norbert Nemec apparently wrote: 
>     else: # for compatibility: 
>         set = {} 
>         for item in inseq: 
>             set[item] = None 
>         if sort: 
>             return asarray(sorted(set.keys())) 
>        else: 
>             return asarray(set.keys()) 

I'm currently in major caffeine deficit,
but aside from backward compatability,
how is this better than:
        else: #for compatability
                items = list(set(inseq))
                if sort: items.sort()
        return asarray(items)

Alan Isaac

PS Actually, making a list of a set may already sort?
No time to check now ...
PPS For to 2.3, need set = sets.Set

More information about the Numpy-discussion mailing list