0 Favourites

Sorting listbox entries via Array/Json load, doesnt work

  • Hi,

    I need to add, remove names in list box. The names need to be sorted, no more than 20 names right now. I tried to us Array for sorting and then load the sorted values into the listbox, but it didnt work. Any idea why not?

    Here is the essential code:

    ButtonAdd onClick & not TextBox is ""

    Array Push back TextBox.Text on X axis

    Array Sort X axis

    List set from JSON string Array.AsJSON

    thanks,

    Daniel

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Hi,

    In the meantime I wasn't able to understand why the json based code doesn't work, but was able to solve the sorting the following way:

    ButtonAdd onClick & not TextBox is ""

    • Array Push back TextBox.Text on X axis
    • Array Sort X axis

    -- Array For each X element

    --- Array Current value =/= 0 List Add Item Array.CurValue

    Also in the Array property menu the dimension of the array has to be set to 1 on each dimension: Width=1, Height=1, Depth=1 otherwise this doesnt work.

    Note that I had to set the condition Array Current value =/= 0, otherwise an empty line would appear in the listbox. This is because the array is prefilled with a first value of zero, because i had to set Width to 1, for the array to receive add values.

    It works, but since i am always interested in learning new techniques, any ideas how to do this better would be much appreciated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
4,517 857,184
Tinimations's avatar
Tinimations
Unread sticky
1,586 437,223
matriax's avatar
matriax
Unread hot topic
378 33,250
part12studios's avatar
part12studios