Using 3.22.13, consider a non-spatial GeoPackage attribute table containing one text field, named "field_a"
. This table has the following form:
fid field_a
1 B
2 A
3 X
4 C
How can I sort the table so that "field_a"
is now permanently sorted in the same ascending order as the "fid"
, as shown below?
fid field_a
1 A
2 B
3 C
4 X
If this sorting requires exporting to a new table, that is acceptable.
I have tried the Order by expression tool with Expression = "field_a"
. Unfortunately, it did not change the sort order in any way.
Edit:
After further review, I've been able to accomplish this task by:
- Exporting the table as a .csv to Excel, without the
"fid"
field - Sorting the .csv within Excel by field_a, then saving
- Add the re-sorted .csv to QGIS
- Export the .csv as a GeoPackage table
Although this works, it is a little kludgy. I'm looking for a more efficient way to do this sorting, preferably within QGIS. Also, I found no plugins that fit this need.