November 08, 2024, 05:40:37 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Sorting lines of code - an IDE future add on?

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

Previous topic - Next topic

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

Why can't you just have one array that is a structure?

type entry
  string Vname
  string Vtype
  string Vvalue
endtype
------------
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

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.