The task is as follows: There is a table with goods, let's say there are 1000 of them, 100 products are displayed on the page. I want to change their order and display NOT the 1st, 2nd, 3rd and so on on the first page. And let's say the 15th, 107th, 1st, 502nd, and so on. The question is how to keep their order in the database (priorities | order_by_id | still like that) with a large number of permutations and how to track these permutations?

  • specify the question. You have already decided that you need a separate field where the number to be sorted will be stored. OK. Further what is the problem? they will not be moving by themselves. We moved one record from position i up to position j , which means everything that was from j+1 to i inclusive should be increased 1. - teran
  • @teran complexity is to avoid overwriting all values ​​when changing the order of several elements. And when adding a new product. - Alexander Nesvat
  • so here you are and describe this particular point in your question. and then there will be no answers in the question, wait, there is no specifics in it. Do you have a billion products there that you can not rewrite numbers? especially not at all, and in part only some, except that you will always add a new product to the beginning. but if the strategy is exactly this, then it can be numbered in reverse order. - teran

0