New UserLib command: SortStructuredArrayFS()

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: New UserLib command: SortStructuredArrayFS()

Post by netmaestro »

In 2006 I was lucky to code something that compiled at all, so the definitive answer is: I haven't a clue if it's stable or not. When something seemed to work, I stopped coding and moved on to something else.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: New UserLib command: SortStructuredArrayFS()

Post by Kwai chang caine »

Never mind MASTER, it's really normal 8)
Each code you create is perfect :shock:

So, the codes is like the programmers, they get older a day :lol:
And sometime it not works after numerous time...

For me, it's a little bit more difficult
When i create a new code..it is already surely very old, :shock: because never it works :mrgreen:
Thanks a lot to exist MASTER 8)
ImageThe happiness is a road...
Not a destination
User avatar
tj1010
Enthusiast
Enthusiast
Posts: 622
Joined: Mon Feb 25, 2013 5:51 pm
Location: US or Estonia
Contact:

Re: New UserLib command: SortStructuredArrayFS()

Post by tj1010 »

I had to sort a structured array once based on a number in a string and ended up just doing a bubble sort on that number because the built in options all do in-order. You can do it with anything just adjusting delay with big data.

Code: Select all

Procedure sort()
  Protected i.l
  Protected indy.l=1
  Protected title$
  Protected desc$
  Protected file$
  For i=0 To ArraySize(items())
    If i>0
      If Val(StringField(items(i)\title$,2," "))<Val(StringField(items(i-1)\title$,2," "))
        ;move up
        title$=items(i-1)\title$ : desc$=items(i-1)\desc$ : file$=items(i-1)\file$
        items(i-1)\title$=items(i)\title$ : items(i-1)\desc$=items(i)\desc$ : items(i-1)\file$=items(i)\file$
        items(i)\title$=title$ : items(i)\desc$=desc$ : items(i)\file$=file$
        file$="" : title$="" : desc$=""
        i=0
      EndIf
    EndIf
    Delay(1)
  Next
EndProcedure
The truth hurts.
Post Reply