It is currently Thu Jan 23, 2020 6:57 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SortList(), SortStructuredList()
PostPosted: Mon Dec 02, 2019 10:25 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3730
Location: Berlin, Germany
Documentation of both SortList() and SortStructuredList() wrote:
Start, End (optional) : The index of the first and last element in the list that should be sorted.

When working with indices, the question is always whether the first index is 0 or 1. This question should be answered in the documentation of SortList() and SortStructuredList().
Even more comprehensive information will be given by linking the word "index" in the sentence above to the help page of ListIndex() (as it was done in the documentation of RandomizeList()).

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: SortList(), SortStructuredList()
PostPosted: Wed Dec 04, 2019 10:28 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Oct 06, 2007 11:20 pm
Posts: 269
Location: France
Hi.
Sortlist is using list(). The first element of a list always start at 0. So, it's the same thing when you're using sortlist etc..
it could be written in each order concerning the lists but it is already indicated in the documentation of the main order "list".

Code:
NewList test()

For i = 1 To 10
  AddElement (test())
  test()=i
Next

RandomizeList (test(),0,9)

ForEach test()
  Debug Str(test()) + " : num " + Str( ListIndex(test() ))  + " from the list"
Next

Debug ""
Debug "Sort_ascending"
Debug ""

SortList(test(), #PB_Sort_Ascending,0,3) ; first element is in position 0 and 4rth element position is 3

ForEach test()
  num.s = Str( ListIndex(test() ))
 
  Debug Str( test() ) + " : num " + num  + " from the list"
  c+1
  If C = 4 : Debug "-----" : EndIf
 
Next


_________________
~Ar-S~

ResizerGold : The easiest way to resize your pictures and more
My webSite (french) : LDVMULTIMEDIA
PB - 5.4x LTS / 5.6x - W10 x64 - GTX1080 - i5 6600k
Repeat : try : until done = 1


Top
 Profile  
Reply with quote  
 Post subject: Re: SortList(), SortStructuredList()
PostPosted: Wed Dec 04, 2019 10:50 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3730
Location: Berlin, Germany
ar-s wrote:
The first element of a list always start at 0.

Yes, I know.
The problem is, that this fact is not mentioned in the documentation of SortList() and SortStructuredList().

Mentioning it anywhere in the "List" chapter of the documentation is not sufficient. When the user wants to learn how to use SortList() or SortStructuredList() properly, s/he should find all required information in the help topic for SortList() or SortStructuredList(), without the need to search elsewhere in the help. The best solution will be to set a link to the help page of ListIndex(), as I wrote above. Exactly this is already done in the documentation of RandomizeList(), so there should be no problem with doing the same in the documentation of SortList() and SortStructuredList().

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye