# Progress towards faster \`sortperm\` for Strings

**URL:** <https://discourse.julialang.org/t/progress-towards-faster-sortperm-for-strings/8505>\
**Category:** Data\
**Tags:** performance, sortperm\
**Created:** [January 21, 2018, 2:04pm UTC](https://discourse.julialang.org/t/progress-towards-faster-sortperm-for-strings/8505 "2018-01-21T14:04:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 21, 2018, 3:51pm UTC](https://discourse.julialang.org/t/progress-towards-faster-sortperm-for-strings/8505/4 "2018-01-21T15:51:39Z")

</div>

At some point I played around with a hybrid representation where strings up to 15 bytes were stored inline with one byte of length in such a way that they integer sort in correct string sort order (store the length in the low byte, pad string data with zeros) and as a pointer to string data otherwise. This not only means that short strings can fit in a single register but also that when comparing two short strings the compare is just an integer comparison. This _flew_ for sorting and basically eliminates any advantage of interning (since interning still requires a pointer to the interned string, which is strictly more storage _and_ more indirection). The problem was that making garbage collection work with this representation was beyond our ability at the time. We may be able to explore such an approach in the future again, however.

---

_[View the full topic](https://discourse.julialang.org/t/progress-towards-faster-sortperm-for-strings/8505)._
