Polling Numbers

Hi,

If I have a listbox with 100 rows and the value is randomly changed.
how to get 10 rows with bigger value, sorted from bigger to smaller.

thanks
regards,
arief

Dont understand the question.

Hi Mr. Tullin.

Basically I want to make ranking for the larger number based from listbox.

For example,
A have data in a listbox like,

Name. Sales

Orange 500
Apple 1500
Banana 10

So want to put ranking label on it

The result should be

Rank 1. Apple. - apple ranking 1st because apple sales is higher
Rank 2. Orange
Rank 3. Banana

So, if i had 100 rows or more, the ranking label should read the higher one.

Thanks
Arief

Do you simply want to sort the Listbox based on the values in Column(1) or do you also want to add a new Column and add Rank <#1> … Rank <last #> ?

In all cases, you have to set code to sort numerically your values in the Sort Event (to add).
Once the above is done and if you want that, Insert a Column in Position #0 and place "Rank " + Format(Row,“0000”).

For the Sort algorythm, you have to search in this forum if the LR (Listbox) does not provide an example (I forgot). The second one is easier.

Assuming you don’t want to sort the listbox, create two arrays. The first will hold the values you want to sort, the second the ListIndex of that values. Then sort the first array with the second (SortWith). The index of each element in the second array will be its ranking.

Hi,

Yes, I don’t want to sort the listbox. I will give a try with an array.

thanks
regards,
arief

Too hard to code ? If so, there is an entry there ListBox (deprecated) — Xojo documentation

Search for Custom Sorting (and the example).

No Emile, he means he doesn’t WANT the listbox to be sorted, not that he doesn’t want to “to the work”

Sorry.

very useful is storing objects (or data) in a rowtag or celltag.

I think, better and faster way is to create in memory sqlite DB, fill it with data and fill the listbox from it.
When you need to do something with data, use sqlite and feel the power.

It is easy to keep things in merge just by creating few methods, which will update both, the sqlite and the listbox

Thanks,

this method is more easier…

regards,
Arief