[jawsscripts] generic sort routine for stringArrays. Is this one ok?

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Mon, 9 Aug 2010 09:32:39 +1000

Hi all,

I've built the below  generic sort routine for string arrays, and am seeking 
advice/comments about its correctness, versatility and efficiency.

The intended purpose is to be able to pass in stringArrays of any size, 
along with their maximum size, and return the sorted array.

As Jaws can not return array variables in the usual way, & by default passes 
arrays byref, it is a void function, & byref is not specified for the array 
variable.

Please advise whether this is a suitable approach, & any 
changes/improvements that may be required.

Void Function ArraySort (StringArray List, int MaxSize)

VAR

INT iIndex,

INT iSwapsRemain,

STRING sTemp

LET iSwapsRemain = True

WHILE iSwapsRemain

LET iSwapsRemain = False

LET iIndex = 1

While (iIndex <= MaxSize - 1)

IF List [iIndex] > List [iIndex + 1] THEN ; swap the values

LET sTemp = List [iIndex + 1]

LET List [iIndex + 1] = List [iIndex]

LET List [iIndex] = sTemp

LET iSwapsRemain = True

ENDIF ; a swap was needed

LET iIndex = iIndex + 1

EndWhile ;still not at the end of the array

EndWhile ;there are more swaps to make

EndFunction



Thank you,

Paul from Aust



?

__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: