[Numpy-discussion] String sort
Charles R Harris
Fri Feb 8 09:19:25 CST 2008
On Feb 8, 2008 5:29 AM, Francesc Altet <email@example.com> wrote:
> I'm a bit confused that the sort method of a string character doesn't
> allow a mergesort:
> >>> s = numpy.empty(10, "S10")
> >>> s.sort(kind="merge")
> TypeError: desired sort not supported for this type
I think it's an error parsing the keyword. In fact, I thought I fixed that,
but maybe I was waiting till I added the other methods.
> However, by looking at the numpy sources, it seems that the only
> implemented method for sorting array strings is "merge" (I presume
> because it is stable). So, perhaps the message above should be fixed.
> Also, in the context of my work in indexing, and because of the slowness
> of the current implementation in NumPy, I've ended with an
> implementation of the quicksort method for 1-D array strings. For
> moderately large arrays, it is about 2.5x-3x faster than the
> (supposedly) mergesort version in NumPy, not only due to the quicksort,
> but also because I've implemented a couple of macros for efficient
> string swapping and copy. If this is of interest for NumPy developers,
> tell me and I will provide the code.
I have some code for this too and was going to merge it. Send yours along
and I'll get to it this weekend.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion