Sorting Custom Arrays

Questions and discussion of Trading Blox and other platforms for non Trading Blox customers. Trading Blox customers should use the Trading Blox Support forum.
Post Reply
CPTRADER
Full Member
Full Member
Posts: 23
Joined: Sat May 28, 2005 8:03 am

Sorting Custom Arrays

Post by CPTRADER »

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.
sluggo
Roundtable Knight
Roundtable Knight
Posts: 2987
Joined: Fri Jun 11, 2004 2:50 pm

Post 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:
Attachments
Shell sort: program code in C
Shell sort: program code in C
sorting.jpg (36.96 KiB) Viewed 8230 times
CPTRADER
Full Member
Full Member
Posts: 23
Joined: Sat May 28, 2005 8:03 am

Post by CPTRADER »

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.
Solong
Roundtable Fellow
Roundtable Fellow
Posts: 87
Joined: Sun Jul 01, 2007 11:24 pm

Post 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.
CPTRADER
Full Member
Full Member
Posts: 23
Joined: Sat May 28, 2005 8:03 am

Post by CPTRADER »

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?
Solong
Roundtable Fellow
Roundtable Fellow
Posts: 87
Joined: Sun Jul 01, 2007 11:24 pm

Post by Solong »

OK. How many elements approximately and how often do you intend to sort?
Tim Arnold
Site Admin
Site Admin
Posts: 9015
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:

Post 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.
Post Reply