JSFiddle - React, Tailwind, and code Playground

by neonms92

HTML

<select data-bind="options: sort(things(),'text'), optionsText: 'text'"></select>

JavaScript

function Model() {
    var self = this;
    self.things = ko.observableArray([]);
    
    self.sort = function(arr, prop) {
        return arr.sort(function (a, b) {
            var item1 = a[prop](), item2 = b[prop]();
            if (item1 < item2)
                return -1;
            if (item1 > item2)
                return 1;
            return 0;
        });
    }
}
function Thing(text) {
    var self = this;
    self.text = ko.observable(text);
}
var model = new Model();
ko.applyBindings(model);
model.things.push(new Thing('C'));
model.things.push(new Thing('A'));
model.things.push(new Thing('B'));