The surprisingly difficult problem of user-defined order in SQL

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • SonarLint - Clean code begins in your IDE with SonarLint
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • SaaSHub - Software Alternatives and Reviews
  • mudderjs

    Lexicographically-subdivide the “space” between strings, by defining an alternate non-base-ten number system using a pre-defined dictionary of symbol↔︎number mappings. Handy for ordering NoSQL keys.

    I have solved this problem for my own purposes — no claims of grand scalability or high efficiency — by storing indices or "ranks" of items as strings (Postgres TEXT) using a library called mudderjs[0] and a thin wrapper around it[1]. Sorted lexicographically (in dictionary order) arbitrary-length strings have arbitrary precision. You can always find a string between any two strings; for instance, between "a" and "b" is "am" and between "a" and "ab" is "aam". You do have to have the entire ordered collection in scope to generate a new rank for an item, but reordering an item only requires updating one row and isn't subject to floating point precision.



  • Awesome Nested Set

    An awesome replacement for acts_as_nested_set and better_nested_set.

  • SonarLint

    Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts