Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is pretty cool!

Honestly I don't think there is a "best" solution here. Even in a "regular" programming language where you can easily use any data structure, it's not obvious which is best for maintaining the order.

Updating the order "value" of all the rows = moving a value around in an array (causing you to also shift a bunch of other values around).

Storing the ID of the row that should show up next in the list (not mentioned in the article, but mentioned in the comments below) = moving nodes around in a linked list.

Creating a new index that will fit in between two existing rows = inserting a value into a tree (because of the index).

It is a little bit trickier in a database, just because, no matter what you do, you also have to pay the price of putting something into a tree as well. Still... I can think of situations where I'd use any of these techniques. In general, this is not a problem with a clean solution for every use case.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: