PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Save an Array Order
Save an Array Order
Iniciado por guest, 14,mar. 2016 08:21 - 5 respuestas
Publicado el 14,marzo 2016 - 08:21
I have an array of class structures, I have a procedure that needs to use ArraySort() and then use ArraySeek(,asBinary,) but when finishes I then need to put the array back in the order it was.

I can't just copy the array as if the value is found that element is deleted from the array.

The procedure can be called from a number of locations and user choices mean I do not know what order the array is in when my seek procedure is called.

Any ideas on how I could do this?

Gary.
Publicado el 14,marzo 2016 - 08:58
Hi, I don't see any other way than to preserve the array "as is" in a CSV file or string by ArrayToCSV(..) or ArrayToString(..) and save it to a file using fSaveText(..). Next time, you can retrieve the file with fLoadText(..) and CSVToArray(..) or StringToArray(..). Here it is then. Unchanged.
Publicado el 14,marzo 2016 - 10:53
Gary,
isn't a linear search fast enough? Then you don't need the intermediate sorting at all
Publicado el 14,marzo 2016 - 17:08
Hi Gary,

You could add an integer member to the structure and fill it sequentially with a serial number from 1 to arraycount.
The you can sort it and later revert to the original orde by sorting on serial number.

Regards,
Piet
Publicado el 14,marzo 2016 - 17:10
Quote
Arie Mars

isn't a linear search fast enough? Then you don't need the intermediate sorting at all

I don't think so, I've done that on a few that have only up to 30 members, but this one may get much larger.

But I'll run some tests and see what the speed difference is based upon the size.
Publicado el 14,marzo 2016 - 17:12
Quote
Piet van Zanten

You could add an integer member to the structure and fill it sequentially with a serial number from 1 to arraycount.

The you can sort it and later revert to the original orde by sorting on serial number.



That might work, will give it a go.

Thanks.