I’m struggling to sort dynamically generated container controls in a web app.
All controllers have a property like “ID” and for a single “addition” of container controls the IDs could be “O”, “A”, “I”, “M”, “UP”, “H”, “UP”, “N”, “”, “UP”.
There will always only be one of the single character-ID’s but there can be an unknown number of “UP’s”.
The single characters should be sorted alphabetically and all of the UP’s should come last.
I’ve been thinking of putting the container controls in an array and sort the array like it’s described here: under “Sorting Arrays of Classes” but that does not solve the problem with the “UP’s”.
Define a property of the container controls where you define a sort priority. Assign priority 1 to those containers that need to come on top, priority 9 to those (like the UP) that need to come on the bottom.
Define a second property that concatenates the new property and the one that you are using now, and then sort according to this new property. That should do the trick, with one or the other solutions that you already explored.
This is a general idea, someone is bound to come up with a better and more elegant solution…