tracker issue : CF-4198572

select a category, or use search below
(searches all categories and all time range)

sort higher order functions should return the sorted object, not simply "YES"

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron ()

Created: 04/30/2017

Components: Language, Functions

Versions: 2016

Failure Type: Others

Found In Build/Fixed In Build: all / 2018.0.0.307160

Priority/Frequency: Normal /

Locale/System: / Platforms All

Vote Count: 4


member functions like Query.sort(), Array.sort() etc should return the sorted collection, not simply return a pointless boolean. Methods cannot be chained if you don't return the object itself.

Also these functions should *not* change the original object, although I get for backwards compat reasons you've perhaps painted yerself into a corner with that.

Changing the methods to at least return the same object should be low-risk as the current return value is not meaningful or useful.



Yes, please. I remember putting in related tickets for the array member functions a long time ago and thought everyone had agreed that returning true/false from a member function was not useful.
Comment by Bradley W.
835 | May 02, 2017 02:04:07 PM GMT
Good point Brad. Perhaps the scope of this ticket should be extended to *ALL* sort member functions? @Adobe, what do you think? If in agreement, can you pls update title, and add a comment to confirm? If you don't agree, can you pls let us know why. Cheers.
Comment by Adam C.
836 | May 02, 2017 02:06:14 PM GMT
Agreed. Returning a boolean is pretty much useless and breaking method chaining breaks up programming flow.
Vote by Carl V.
838 | May 02, 2017 04:00:04 PM GMT
Agree, should return the object not a boolean.
Vote by Peter F.
839 | May 02, 2017 06:51:30 PM GMT
+1 and fix struct.sort() to return a sorted struct in cfscript 2.0. Let's clean-up the language a bit.
Vote by Aaron N.
840 | May 04, 2017 05:10:51 AM GMT
Hi Adobe, I see this ticket's status is "To Fix". What, specifically, will be fixed? Additional question: Will struct.sort() return a sorted struct in cfscript 2.0? Thanks!, -Aaron
Comment by Aaron N.
837 | July 01, 2017 02:02:14 AM GMT
*bump* Can anyone from Adobe respond? I see the ticket is now Closed/Fixed. What, specifically, was the fix? Thanks!, -Aaron
Comment by Aaron N.
27297 | April 05, 2018 06:29:43 AM GMT
@Aron : We didn't have the overloaded version of the function which takes a callback and return the sorted object . We have implemented that function which will return the sorted List as well.
Comment by Ashudeep S.
27309 | April 06, 2018 09:40:02 AM GMT