Post Reply 
Custom sort?
01-21-2019, 10:56 AM
Post: #7
RE: Custom sort?
(01-20-2019 11:38 PM)Didier Lachieze Wrote:  The CAS sort function works differently than the HOME SORT function for the second argument, it should define a function to be used for the sorting.

In CAS :
sort({{1,2},{2,2.5},{3,1.5}},(x,y)->when(x[2] = y[2],x[1]>y[1],x[2]>y[2]))
returns:
{{2,2.5},{1,2},{3,1.5}}

The sorting is done on the second item in descending order, and if the second item is the same, on the first item also in descending order.

With only the provided hp documentation, using a function as the second argument isn't shown. In the original example, if sort() is given as the [CAS]command, it gets case-changed to SORT(), which doesn't work when the format used follows either the User Guide, or the on screen help guidance.

For the CAS side, perhaps SORT({{1,2},{2,2.5},{3,1.5}},2), should just return, "Error: Bad argument error."

Another approach could be to suggest: See XCAS help, (an external resource). This idea connects the CAS side with XCAS, and hints that the XCAS help could be useful for this, and perhaps other CAS needs.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Custom sort? - EricR - 01-20-2019, 06:09 PM
RE: Custom sort? - pier4r - 01-20-2019, 06:50 PM
RE: Custom sort? - Didier Lachieze - 01-20-2019, 08:20 PM
RE: Custom sort? - DrD - 01-20-2019, 09:13 PM
RE: Custom sort? - Didier Lachieze - 01-20-2019, 11:38 PM
RE: Custom sort? - Albert Chan - 01-21-2019, 03:05 AM
RE: Custom sort? - John Keith - 01-22-2019, 04:23 PM
RE: Custom sort? - Albert Chan - 01-22-2019, 05:34 PM
RE: Custom sort? - DrD - 01-21-2019 10:56 AM
RE: Custom sort? - informach - 01-22-2019, 06:54 PM
RE: Custom sort? - StephenG1CMZ - 01-23-2019, 01:53 PM



User(s) browsing this thread: 2 Guest(s)