# WIP: faster string sort

**URL:** https://discourse.julialang.org/t/wip-faster-string-sort/7671
**Category:** Internals & Design
**Tags:** strings, sort
**Created:** [December 10, 2017, 11:54am UTC](https://discourse.julialang.org/t/wip-faster-string-sort/7671 "2017-12-10T11:54:40Z")
**Posts on this page:** 1
**Showing post:** 45

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [December 25, 2017, 1:27pm UTC](https://discourse.julialang.org/t/wip-faster-string-sort/7671/45 "2017-12-25T13:27:46Z")

</div>

I did a [quick implementation of MSD string radixsort in C](https://gist.github.com/xiaodaigh/bebc7f4e332e1aa222610418374e16a5) (btw most C radixsort found on google were “joke” implementations mostly) and it was slow compared to the implementation in Julia. So not very useful as a benchmark since it’s so unoptimised. I also found [this lecture](http://www.cs.princeton.edu/courses/archive/spring03/cs226/lectures/radix) which contains some useful algorithms to try.

Here is how I am calling the C radixsort in Julia

```julia

cradixsort(x) = ccall(
    (:radix_sort,"libuntitled3"),
     Void, 
     (Ptr{Ptr{UInt8}},UInt),
    pointer(x), length(x)
)

const M = 100_000_000; const K = 100;
srand(1);
svec = rand(["id"*dec(k,10) for k in 1:M÷K], M);

# yy = svec[1:2_000_000];
@time cradixsort(svec) # 2.5 minutes
issorted(svec)

using FastGroupBy

@time radixsort!(svec) # 18 seconds
issorted(svec)

```

---

_[View the full topic](https://discourse.julialang.org/t/wip-faster-string-sort/7671)._
