From f9f102045096143998e75294dc3d409fc807819e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 6 Jun 2016 15:14:14 -0400 Subject: Added an optimization in fuzzy sorting --- fuzzel.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fuzzel.lua') diff --git a/fuzzel.lua b/fuzzel.lua index f3432dc..894fd07 100644 --- a/fuzzel.lua +++ b/fuzzel.lua @@ -223,17 +223,17 @@ local function FuzzySort(str, func, ...) --Roughly sort everything by it's distance to the string local usorted = {} + local sorted = {} for k,v in prs(looparg) do local dist = func(str,v) - usorted[dist] = usorted[dist] or {} + if usorted[dist] == nil then + usorted[dist] = {} + tblins(sorted,dist) + end tblins(usorted[dist],v) end --Actually sort them into something can can be iterated with ipairs - local sorted = {} - for k,v in prs(usorted) do - tblins(sorted,k) - end tblsrt(sorted) --Then build our output table -- cgit v1.2.3-70-g09d2