Interestingly, I ran into exactly the same problem last week. I fixed it in the following way:
It's terribly inefficient, but a discussion on my company Sprintr hasn't resulted in a better solution yet. I'm still interested in a better solution though.
The ideal situation for us is to sort on the enum values in the order they are defined in the model. Unfortunately this is not the case at the moment but that is a situation we want to go towards.
This is the ideal scenario in most cases. For example, consider enums with:
None of these should be sorted lexicographically, neither on the caption in whatever language, nor the actual value.
Of course, to sort lexicographically based on the value and not the caption, all you'd have to do is order them in that way, so you could still do that even in that situation.
Sorting an enum on the caption of a specific language is not likely to be implemented though, not only would all the translations have to be stored in the database, but you would also need additional joins in your queries in order to sort correctly, resulting in a performance loss.
For your situation, wouldn't it be better to have the countries as an entity instead of an enum? Even though new countries don't often get created, it would seem convenient to be able to add them without having to make model changes. Also I don't know what you use them for but it doesn't seem likely you're selecting them that often that you really need the performance of an enum.
Hi Ronald,
Just a vague response or idea. This is not much.
if i understand your problem, then you want to display values of the enumeration as sorted, based on the chosen locale/language. Hence i guess there would be way to do that. As in java lets say you have a list of strings in german and you want to display them in sorted order, then in order to do that we use Collator class get the instance on that specific locale and then sort.
i dont know whether that is possible with mendix enum or not. As per my understanding they are basically 2 D arrays.