Fixed
Details
Assignee
Michael OffnerMichael OffnerReporter
Adam CameronAdam CameronNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Priority
Minor
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Adam Cameron
Adam CameronNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Priority
Created 2 May 2017 at 08:59
Updated 30 April 2024 at 18:23
Resolved 30 April 2024 at 18:23
See http://blog.adamcameron.me/2017/04/cfml-lucee-13-v-4-14-v-6-coldfusion-we.html
See this test case:
component extends="testbox.system.BaseSpec" { function run() { describe("Other sort tests", function(){ it("is a baseline showing using BIFs as a callback", function(){ var testString = "AbCd"; var applyTo = function(object, operation){ return operation(object); }; var result = applyTo(testString, ucase); expect(result).toBeWithCase("ABCD"); }); describe("using arrays", function(){ it("can use a function expression calling compareNoCase as a string comparator when sorting", function(){ var arrayToSort = ["d","C","b","A"]; arrayToSort.sort(function(e1,e2){ return compareNoCase(e1, e2); }); expect(arrayToSort).toBe(["A","b","C","d"]); }); it("can use the compareNoCase BIF as a string comparator when sorting", function(){ var arrayToSort = ["d","C","b","A"]; arrayToSort.sort(compareNoCase); expect(arrayToSort).toBe(["A","b","C","d"]); }); }); describe("using lists", function(){ it("can use a function expression calling compareNoCase as a string comparator when sorting", function(){ var listToSort = "d,C,b,A"; var sortedList = listToSort.listSort(function(e1,e2){ return compareNoCase(e1, e2); }); expect(sortedList).toBe("A,b,C,d"); expect(listToSort).toBe("d,C,b,A"); }); it("can use the compareNoCase BIF as a string comparator when sorting", function(){ var listToSort = "d,C,b,A"; var sortedList = listToSort.listSort(compareNoCase); expect(sortedList).toBe("A,b,C,d"); expect(listToSort).toBe("d,C,b,A"); }); }); }); } }
Specifically:
arrayToSort.sort(compareNoCase);
And:
var sortedList = listToSort.listSort(compareNoCase);