From b85ba52514e3521a078c969990bb4df1f287e03f Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Wed, 18 Nov 2015 11:43:49 +0100 Subject: [PATCH] Allow more advanced sorting --- awesomplete.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/awesomplete.js b/awesomplete.js index a422d1bf..872b7e28 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -219,11 +219,16 @@ _.prototype = { // Populate list with options that match this.ul.innerHTML = ""; - this._list + var filtered = this._list .filter(function(item) { return me.filter(item, value); }) - .sort(this.sort) + + var sorted = this.sort.length === 1 + ? this.sort(filtered) + : filtered.sort(this.sort); + + sorted .every(function(text, i) { me.ul.appendChild(me.item(text, value));