Sorry about the delay, I can only answer half of your question.
Select2 provides the `sorter` option (previously called `sortResults`) which takes in the array of results to be displayed and expects a sorted array to be returned as a result. Select2, by default, does not do any special sorting and just passes the original array of results through. You can override the `sorter` method (it's a function) when you initialize Select2.
Also note that only the first parameter (`results`) is supported in Select2 4.0.0.
The two links you provided were about ordering the selection, not the results.