I am trying to: Show a list of properties sorted by their property numbers as numbers not as alphabetical sorting (so 2 comes before 17, for example). This works fine in the main view but I also have a filter where the user can filter the list of properties based on activities available. In the filtered results list, the order still uses the property number but it shows in alphabetic order, not numeric order (9 comes after 10, 2 comes after 17, etc.)
Link to a page where the issue can be seen: hidden link
I expected to see:
The list always sorted by property number, numerically, whether the filter is applied or not.
Instead, I got:
The list is sorted numerically at first but when the filter is applied, it still filters on the correct field but alphabetically instead of numerically.
Screenshot shows sort setting is property number, ascending, as a number.
Hello. Thank you for contacting the Toolset support.
Well - can you please share access details so I can review your current setup and check whats going wrong there.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Well - I've changed your field type to the numeric field for the field "Property Map Number" which was set to "Single Line" field before.
=> hidden link
I can see now, the listing is sorted now as expected.
=> hidden link
Can you please confirm it works at your end as well.
Is there no way to treats numbers as numbers but not use a numeric field? This site needs the flexibility to have a property number such as 14a so changing the field to numeric is not the ideal solution. We just need digits (0-9) sorted numerically if they appear at the beginning of the field contents.
Well - what you said both are a different thing. Either you can sort by number or text. If you set to text sort, you will get the results what you have had before and if you change it to number, it will work like after I made the change.
Then why do I have the option to set it to "As a Number" in the View editor if it is a single line field instead of a number field? And why does it work correctly before I apply a filter?
I'd think all the "As a Number" setting does is add the SORT_NUMERIC parameter to PHP's sort function or meta_value_num in the WordPress query. It shouldn't matter whether the field type is number or single line with either of those. When the filter is applied, whatever was being done correctly in the original sort is lost and the sort reverts to alpha. That seems like a bug, not an issue with field type.
Can you escalate this to development and have them check whether it is supposed to work or not?
We changed the field to a number for now as we don't have any alphanumeric property entries yet (ie. 14a). This was simpler than adding the custom code you provided. We'd like to change the field back to single line when this is officially fixed in a future update. For now, you can close this ticket as long the bug is on the dev team's bug list.
I would like to inform you that the latest release of Toolset Views version 3.0.2, includes a fix for this issue. Please feel free to update the Toolset views.