template/static/scripts/bootstrap-typeahead.js
function (items) {
            var that = this,
                beginswith = [],
                caseSensitive = [],
                caseInsensitive = [],
                item;

            while (item = items.shift()) {
                if (!item[that.options.display].toLowerCase().indexOf(this.query.toLowerCase())) {
                    beginswith.push(item);
                }
                else if (~item[that.options.display].indexOf(this.query)) {
                    caseSensitive.push(item);
                }
                else {
                    caseInsensitive.push(item);
                }
            }

            return beginswith.concat(caseSensitive, caseInsensitive);
        }
function (items) {
            var that = this,
                beginswith = [],
                caseSensitive = [],
                caseInsensitive = [],
                item;

            while (item = items.shift()) {
                if (!item[that.options.display].toLowerCase().indexOf(this.query.toLowerCase())) {
                    beginswith.push(item);
                }
                else if (~item[that.options.display].indexOf(this.query)) {
                    caseSensitive.push(item);
                }
                else {
                    caseInsensitive.push(item);
                }
            }

            return beginswith.concat(caseSensitive, caseInsensitive);
        }
function ( items ) { var that = this , beginswith = [ ] , caseSensitive = [ ] , caseInsensitive = [ ] , item ; while ( item = items . shift ( ) ) { if ( ! item [ that . options . display ] . toLowerCase ( ) . indexOf ( this . query . toLowerCase ( ) ) ) { beginswith . push ( item ) ; } else if ( ~ item [ that . options . display ] . indexOf ( this . query ) ) { caseSensitive . push ( item ) ; } else { caseInsensitive . push ( item ) ; } } return beginswith . concat ( caseSensitive , caseInsensitive ) ; }
------------------------------------------------------------------  Sorts the results
------------------------------------------------------------------ Sorts the results