Post Reply 
Finding minimum in list
03-25-2017, 02:25 PM (This post was last modified: 03-25-2017 02:26 PM by DrD.)
Post: #10
RE: Finding minimum in list
(03-22-2017 03:30 PM)Han Wrote:  In the event of two or more sublists having the same minimal first values, the first occurrence will be used. Did you have any other conditions for such cases?

My application needs the first occurrence of multiple sublists which have the same minimum first values. At first, I thought this is what the SORT command would do. However, I've found that isn't always true :

L0:={{10,1},{2,2},{2,4},{8,9},{8,1}};
SORT(L0,1); // ==> {{2,4},{2,2},{8,9},{8,1},{10,1}}

The set of sublists with 2 as the first value get reversed in the SORT procedure, whereas the set of sublists with 8 as the first value do not get reversed. SORT cannot be relied upon to return the first occurrence for same sublist first values. This behavior can be difficult to debug, in otherwise normally functional code!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Finding minimum in list - DrD - 03-22-2017, 03:14 PM
RE: Finding minimum in list - Han - 03-22-2017, 03:30 PM
RE: Finding minimum in list - DrD - 03-22-2017, 05:29 PM
RE: Finding minimum in list - Han - 03-22-2017, 05:42 PM
RE: Finding minimum in list - Tyann - 03-23-2017, 05:38 AM
RE: Finding minimum in list - DrD - 03-25-2017 02:25 PM
RE: Finding minimum in list - Han - 03-25-2017, 03:10 PM
RE: Finding minimum in list - Han - 03-22-2017, 04:11 PM
RE: Finding minimum in list - Han - 03-22-2017, 04:32 PM
RE: Finding minimum in list - DrD - 03-23-2017, 10:18 AM
RE: Finding minimum in list - John P - 03-26-2017, 04:11 AM
RE: Finding minimum in list - DrD - 03-28-2017, 01:52 PM
RE: Finding minimum in list - DrD - 03-29-2017, 10:54 AM



User(s) browsing this thread: