Fork me on GitHub

Keep rendering sort

HTML
<div class="row">
    <div class="col-xs-5">
        <select name="from[]" id="customSort" class="form-control" size="8" multiple="multiple">
            <option value="1">Item 1</option>
            <option value="5">Item 5</option>
            <option value="2">Item 2</option>
            <option value="4">Item 4</option>
            <option value="3">Item 3</option>
        </select>
    </div>
    
    <div class="col-xs-2">
        <button type="button" id="customSort_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
        <button type="button" id="customSort_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
        <button type="button" id="customSort_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
        <button type="button" id="customSort_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
    </div>
    
    <div class="col-xs-5">
        <select name="to[]" id="customSort_to" class="form-control" size="8" multiple="multiple"></select>
    </div>
</div>
JavaScript
<script type="text/javascript">
jQuery(document).ready(function($) {
    $('#customSort').multiselect({
        sort: {
            left: function(a, b) {
                return a.value > b.value ? 1 : -1;
            },
            right: function(a, b) {
                return a.value > b.value ? -1 : 1;
            }
        }
    });
});
</script>