In QGIS 3 the Field calculator has a great function called @row_number
(in QGIS 2 it was $rownum
) which returns (assigns) the number of the current row.
Is there a way to make it work together with sorting?
Let's say I want to sort table by column "length"
and get the order (sequence) of lines by length from shortest to longest.
I know I can use some office spreadsheet software easily for this to sort by column and populate new column with order (sequence). But I would prefer to do the whole job in QGIS.
As workaround there is also Changing order of features in shapefile - using MMQGIS Plugin and function modify/sort and after that use @row_number
($rownum
) on the new saved file.