Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Minimum
Message
From
24/06/2014 08:54:35
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
24/06/2014 05:02:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01601946
Message ID:
01602279
Views:
77
>Huh? for just finding the minimum, stepping once through the store is the fastest option, differences come from implementation details like language. And as the time to sort big arrays increases more than the stepping approach, unless afterwards an operation on sorted items is needed, asort() feels like a bad idea unless used for a particular spot, but not as a common way to resolve the question.

Implementation detail: ASORT is C code. A do while loop is Fox higher level pseudo compiled code. Wouldn't asort be fastest until the list had thousands of entries? Just curious


>
>
>
>>For your ARRAY, whats wrong with ASORT() ?
>>>
>>>That begs the question what are you doing that for? To go through a list of items of any length and grab the minimum and then have a pointer to the item is a piece of cake.
>>>
>>>If you have an array with values
>>>
>>>
DIMENSION laList[2]
>>>laList[1]=10
>>>laList[2]=20
>>>lnMin=laList[1]
>>>lnPointer=1
>>>FOR X=2 TO ALEN(laList,1)
>>>  if laList[m.x] < lnMin
>>>    lnMin = laList[m.x]
>>>    lnPointer = m.x
>>>  endif
>>>ENDFOR
>>>
>>>?"the row with the minimum value is ",m.lnPointer
>>>
>>>With a cursor
>>>
>>>
calculate mix(field) to m.lnMin
>>>locate for field=m.lnMin
>>>lnPointer=recno()
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform