Re: [BLACKBOX] Sorting a Dialog.List

From: [at]} <Chris>
Date: Sun, 16 Sep 2012 11:24:52 +0930

----boundary-LibPST-iamunique-1286148116_-_-
Content-type: text/plain

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Walkden
> Sent: Sunday, 16 September 2012 2:25 AM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: Re: [BLACKBOX] Sorting a Dialog.List
>
> > From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> > Campbell, Robert (SELEX GALILEO, UK)
> > Sent: 14 September 2012 12:02
>

> > \\ Even a bubble sort would be much faster if it could be run

> > inside the Dialog module Just curious - is there any sorting
> > algorithm that
> works effectively with a single linked list structure?
>
> If there is one which reorganises the list itself I'd guess it's
> fiendishly complicated for little if any performance gain over a
> simple copy from the original list into an ordered list. Inserting
> into an ordered list is quite straightforward.
>

I usually use QuickSort for this sort of thing. It is fairly simple to
implement (if you follow an existing source code example) and it has been
more than efficient for any of my applications to date.

Another possible approach to Stephen's application would be to first copy
the Dialog list to a temporary list of *pointers* to strings so that only
the pointers are shuffled during the sort not the entire contents of each
string. Also the Compare function used does not need to access every
character in a pair of strings to do its job. Once they were sorted they
would be copied back to the Dialog list.

Niklaus Wirth devotes 40 pages to the description, Oberon source code
examples and performance analysis of many different sorting methods in his
"Algorithms and Data Structures" book. If there is a different answer to
Robert's question it might be in there somewhere. The book is available as a
PDF download from:

The original 2004 Oberon version:

http://www.ethoberon.ethz.ch/books.html

or the 2012 version with some changes that resulted from the efforts to
translate it into to Russian:

http://www.inr.ac.ru/~info21/ADen/AD2012.pdf

Regards,
Chris

--
Chris Burrows
Astrobe v4.2: Oberon for ARM Cortex-M3 Microcontrollers 
http://www.astrobe.com
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1286148116_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1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l0aCBzb21lIGNoYW5nZXMgdGhhdCByZXN1bHRlZCBmcm9tIHRoZSBl
ZmZvcnRzIHRvXHBhcg0KdHJhbnNsYXRlIGl0IGludG8gdG8gUnVzc2lhbjpccGFyDQpccGFyDQpo
dHRwOi8vd3d3Lmluci5hYy5ydS9+aW5mbzIxL0FEZW4vQUQyMDEyLnBkZlxwYXINClxwYXINClJl
Z2FyZHMsXHBhcg0KQ2hyaXNccGFyDQpccGFyDQotLVxwYXINCkNocmlzIEJ1cnJvd3NccGFyDQpB
c3Ryb2JlIHY0LjI6IE9iZXJvbiBmb3IgQVJNIENvcnRleC1NMyBNaWNyb2NvbnRyb2xsZXJzIFxw
YXINCmh0dHA6Ly93d3cuYXN0cm9iZS5jb21ccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8g
dW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIg
dG8gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXH19AEBMSQ==
----boundary-LibPST-iamunique-1286148116_-_---
Received on Sun Sep 16 2012 - 03:54:52 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:55 UTC