TIP: Click on subject to list as thread! ANSI
echo: clipper
to: ALL
from: ERIK WACHTMEESTER
date: 1997-08-02 15:03:00
subject: Codeblocks and arrays

Reply-To: erik.wachtmeester@bighole.iaf.nl
I'm using codeblocks quite a lot, but now I encountered a problem I don't 
know how to solve.
Is it possible to use the asort-way of using a codeblock (something like {
|x,y| x[nOffset] < y[nOffset] } ) in a UDF that manipulates an array about 
he
same way asort() does?
The reason why I'm asking: asort() doesn't always do what I want: if 2 or 
ore
sorting criteria are the same, the array elements should stay in the original
order in the array. And asort() (using a quicksort or a shellsort, I don't 
know)
doesn't do that. A simple bubblesort does, at the cost of being a bit slower,
but that's acceptable if the array isn't that big.
But, how do I write a universal bubblesort routine that accepts an asort-like
codeblock?
It's the |x,y| part that intrigues me. All codeblocks on arrays I use use 
ero
or one local, as do all the programming examples I've seen.
So it isn't the sort routine I'm interested in (I know how to write a
quicksort, shellsort, insertion sort, etc.), but the way how asort() parses 
it's
codeblocks.
Regards,
Erik 
---
---------------
* Origin: May it be on this earth? (2:283/7.2)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.