Page 1 of 1

Sorting Custom Arrays

Posted: Fri Jul 04, 2008 3:28 pm
Hello, I understand that TBB does not have a inbuilt function for sorting custom arrays.

Have any of you found a workaround i.e. a custom created TBB function/script to sort your custom arrays since there is no TBB inbuilt sort array function?

Thanks for your help.

Posted: Fri Jul 04, 2008 4:11 pm
by sluggo
If you're going to code your own sort in Blox BASIC, the Shell sorting algorithm is probably a good compromise between simplicity and speed. It's only a tiny bit more complicated than a traditional Bubble sort or Insertion sort, but it runs signigicantly faster, especially when sorting more than two dozen entries. Here is Sedgewick's implementation:

Posted: Fri Jul 04, 2008 4:40 pm
Thanks sluggo, while I don't have access to the Customer site... I see that you are a tremednous resource to the tBB community.

I am NOT a prficient C coder.

Do you have a code example I can directly use in TBB.

I am considering purchasing TBB, but given the limited 7 day trial window, I want to be sure I can at least code all my current systems in TBB before downloading the trial version. The array sort feature is important to me.

Thanks again fr your help and please let me know if you have a direct TBB example iusing TBB Basic that I can use to sort my custom arrays.

Posted: Fri Jul 04, 2008 5:36 pm
by Solong
It is a good question. If the list to be sorted is numeric and not strings, and the number of elements do not exceed the number of instruments, there is another possibility involving the functions SortInstruments and SetLongRankingValue (or -Short-).

This use may not be official or recommended but I have made use of it. It is not the all-purpose sort function that you're looking for, but possibly the work-around you're looking for.

If you also use proper instrument ranking in your system, remember to first save the existing ranks and then repopulate them after your custom sort.

Posted: Fri Jul 04, 2008 5:43 pm
Thanks solong. Good answer. Unfortunately, while my list i snumeric, the number of elemnets far exceeds the number of instruments; so your workaround unfortunately appears not to be valid.

Thanks anyway for your contribution.

Any other ideas?

Posted: Sat Jul 05, 2008 4:27 pm
by Solong
OK. How many elements approximately and how often do you intend to sort?

Posted: Sat Jul 05, 2008 6:02 pm
by Tim Arnold
I have added the ability to sort custom arrays. This feature will be available in the next beta release for testing. Please post examples of usage here so we can be sure the architecture will meet your needs.