constellation
constellation copied to clipboard
Sort numbers numerically in the Table View
Prerequisites
-
[X] Put an X between the brackets on this line if you have done all of the following:
-
Running the latest version of Constellation
-
Attached the Support Package via
Help
>Support Package
-
Checked the FAQs: https://github.com/constellation-app/constellation/wiki/FAQ
-
Checked that your issue isn’t already filed: https://github.com/constellation-app/constellation/issues
-
Checked that there is not already a module that provides the described functionality: https://github.com/constellation-app/constellation/wiki/Catalogue-of-Repositories
-
Description
The Table view sorts columns with numbers alphanumerically instead of numerically. For example, instead of:
1
10
100
2
it should be:
1
2
10
100
Steps to Reproduce
- File -> New Graph
- Experimental -> Build Graph -> Small world graph
- Open the Table View
- Switch to the nodes mode
- Add the x attribute as a column
- Sort the column
Expected behaviour: [What you expect to happen] Column should be sorted numerically
Actual behaviour: [What actually happens] Column is sorted as Strings instead
Reproduces how often: [What percentage of the time does it reproduce?] 100
A quick dig into the code confirms that the table has been constructed such that all inputs are Strings (hence all columns including ones that would appear to be numeric are sorted lexicographically). A refactor of a number of parts of the table would be required then in order to be able to handle numerical values properly
@antares1470 I first attempted to refactor the table columns and associated variables to the type of Object so that the columns themselves would infer the type, String or Integer, then sort accordingly.
That didn't seem to work so I tried implementing a custom comparator on the SortedList that populates the columns. It was either not being bound properly or being overridden at a later stage so that didn't affect the sorting either.
After discussing with @formalhaunt, a possible solution is to implement a comparator on the table columns as they are being created in Table.java.
This issue is stale because it has been open for 6 months with no activity. Consider reviewing and taking an action on this issue.
Thank you @OrionsGuardian for fixing this up. This is super handy now and I can now sort on all the columns in the Table view as I would expect (text sorting correcting, numbers sorting correctly). Thank you!!