Thanks sneakypete92
I followed your latest post and I sorted it, hopefully forever, out. But what we have just done is a manual solution, system itself shouldn't mess it up just like that. Every time you use arrows to place your features in right order, system saves it in database, but in fact it doesn't. Second thing is that system should not assign doubled position's numbers, just like I had (two different id_features had the same position). As a conclusion, I would like to ask anyone to change script in such way that it cannot be possible for system to allocate two or more id_feature to one position. Many thanks in advance. And thank you sneakypete92 again.