English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 03 June 2018, 06:56   #1
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
Sortlist command

Simple question... what's the syntax of the Sortlist command on BLitz 2?

I just cant use it.

I have a list called "objects"

I've tried

SortList objects
SortList objects()
SortList (objects)
SortList (objects())

all of them give me syntax errors

How do I use this command?

Thank you!
Shatterhand is offline  
Old 03 June 2018, 07:21   #2
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
The manual says:

SortList Arrayname()
... The order in which the items are sorted depends on the first field of the linked list type which must be a single integer word...
MickGyver is offline  
Old 03 June 2018, 07:22   #3
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
Thank you, but I do have the manual open all time, I had already seen what the manual says. It still doesn't help me at all. (The manual is very vague on many points unfortunately)
Shatterhand is offline  
Old 03 June 2018, 10:17   #4
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Yep, I agree that the manual can be a bit vague. Does this help at all, it has some sizeof argument?

http://amiga.sourceforge.net/amigade...&action=Search
MickGyver is offline  
Old 03 June 2018, 23:23   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Yeah, you need to tell it the size of the elements in the array you're sorting. This makes it a much faster command because it can then make assumptions on how many bytes to move instead of having to calculate it. The sizeof argument is the number of bytes a single element of the list takes up. You can either provide the absolute number, like this:

Code:
SortList objects(), 4
if objects() is an array of 4-byte elements, such as Longs or Quicks, or a Newtype consisting of a Word and two Bytes. It might be safer however to use the SizeOf keyword to get the compiler to put in the size for you - that way, if you modify the Newtype, the new size is automatically adjusted:

Code:
SortList objects(), SizeOf .l
or

Code:
SortList objects(), SizeOf .myNewType
Daedalus is offline  
Old 04 June 2018, 02:59   #6
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
GODDAMN IT the Manual says absolutely NOTHING about this! Thank you guys for the help!
Shatterhand is offline  
Old 04 June 2018, 15:06   #7
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
If you wanted to reverse-sort the list you'd need to store the complement of the sort criteria, I guess? A bit of a pain.
E-Penguin is offline  
Old 04 June 2018, 15:21   #8
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Depending on what you're sorting, the RISortLib might be of use to you. It can perform alphabetical sorting of a linked list array in either order. Numerical sorting in reverse order doesn't appear to be that easy, however I think it's not that bad if the list is being traversed - just work upwards instead of downwards.
Daedalus is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Final Command runamuck2 support.Games 7 13 September 2019 16:17
Is there a WB command at all that can... MethodGit request.Other 43 10 October 2010 09:06
What is the WB command that..... MethodGit request.Other 4 08 October 2010 04:21
msdos command ? turrican3 request.Apps 31 16 January 2008 03:05
command line? Drake1009 support.WinUAE 7 14 August 2004 17:17

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:54.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.20641 seconds with 15 queries