2

I'm trying to sort my numerical values in my attribute table but instead of getting 1, 2, 3 I get 1, 10, 100, 100 etc. When searching for a solution here on Stack Exchange, many people with earlier versions just had to update to a later one, 2.18 e.g. However, I still have this problem for my 3.4.4 version. How can I solve this bug?

  • 1
    where did your data come from? – Ian Turton Feb 20 at 10:52
  • 4
    What is the field type of the field containing the values? – Joseph Feb 20 at 10:55
  • @IanTurton It's from the Swedish Land Surveying Agency's open data on the road network – Felix Althén Bergman Feb 28 at 14:11
6

It sounds like the field's data type is Text. So it's sorting the numbers alphabetically.

Create a new field and populate it using the field calculator with

to_int("Your_Field")

The new field should sort numerically.

Bear in mind that this will only work for features which do not have any actually text characters in them.

  • 1
    You dont need to create a new field or even a virtual field, just right click on the a column header and choose "sort..." and you will access a calculator where you can enter the formula for sorting (in this case : to_int("Your_Field") ) strangely this formula work even if some feature have text character but the non numerical didn't seem to be sorted (the purely numerical get sorted at top or bottom depending in sort order) – J.R Feb 20 at 13:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.