July 23, 2024, 09:51:44 AM

## News:

IWBasic runs in Windows 11!

## Sorting lines of code - an IDE future add on?

Started by Andy, October 28, 2017, 03:55:46 AM

0 Members and 1 Guest are viewing this topic.

#### Andy

##### November 03, 2017, 11:04:04 PM #25 Last Edit: November 03, 2017, 11:50:00 PM by Andy
So I would like to try this quick sort in my reg viewer program, I've already done it with Clint's bubble4 code which is great / fast.

This is the query:

I have three columns to display - Entry name, type and value...

e.g.

MyRegEntry                  string                   "This is a string entry"

Now array 2 holds the type "string" and array 3 holds the value "This is a string entry", these 2 arrays relate to array 1 - the entry name.

With Clint's code it was straight forward to keep array 2 and 3 in line with array 1.

` loops++ for x = 1 to repop-1 if Vname[x]>Vname[x+1] string tempName = Vname[x+1] string tempType = Vtype[x+1] string tempValue = Vvalue[x+1] Vname[x+1]  = Vname[x] Vtype[x+1]  = Vtype[x] Vvalue[x+1] = Vvalue[x] Vname[x]  = tempName Vtype[x]  = tempType Vvalue[x] = tempValue swap++ change=1 endif next x`

Where array 1 (to be sorted) is Vname, array 2 is Vtype, and array 3 is Vvalue.

Any ideas anyone?

BTW:
I didn't realise how much of a bottleneck the sort was in my reg viewer program, with Clint's code the program works so quick now - thanks Clint.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

#### LarryMc

##### November 04, 2017, 10:26:16 AM #26
Why can't you just have one array that is a structure?
`type entry  string Vname  string Vtype  string Vvalueendtype------------entry z[10000]----------- loops++ for x = 1 to repop-1 if z.Vname[x]>z.Vname[x+1] string tempName = z.Vname[x+1] z.Vname[x+1]  = z.Vname[x] z.Vname[x]  = tempName swap++ change=1 endif next x`
LarryMc
Larry McCaughn
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

#### Andy

##### November 04, 2017, 11:06:38 AM #27
Larry,

Good to see you around again. Yes I came to the same conclusion, I tried the quick sort but for the numbers involved I didn't see any improvement.

But good to see you posting again.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.