what the heck.
Just copied this from the help file. Worked great, until I limited the length
of that string Name${10}.
Again, my logic is sleeping right now. But my finger aren't.
Don't get me wrong, I know how to fix it, I'm just wondering if by default
this would be a bug, or user error.

- np
Code: Select all
 Structure Animal
    Name${10}
    Speed.l
  EndStructure
  
  Dim Animals.Animal(2)
  
  Animals(0)\Name$ = "Tiger"
  Animals(0)\Speed = 10
  
  Animals(1)\Name$ = "Jaguar"
  Animals(1)\Speed = 40
  
  Animals(2)\Name$ = "Zebre"
  Animals(2)\Speed = 30
  
  ; Sort the array on the 'name$' field, which is a string
  ;
  SortStructuredArray(Animals(), 0, OffsetOf(Animal\Name$), #PB_Sort_String)
  
  For k=0 To 2
    Debug Animals(k)\Name$+" - Speed: "+Str(Animals(k)\Speed)
  Next
  
  ; Sort the array on the 'speed' field, which is a long
  ;
  SortStructuredArray(Animals(), 0, OffsetOf(Animal\Speed), #PB_Sort_Long)
  
  For k=0 To 2
    Debug Animals(k)\Name$+" - Speed: "+Str(Animals(k)\Speed)
  Next



