Announcement
Collapse
No announcement yet.
Control Sorting
Collapse
X
-
Hi, thanks, well never mind about the % because I forgot I had the raw data to make the % so I just sorted that instead.
-
Shrek
I could not understand what did you mean by percentage
If you could elaborate a bit more then i would help on that as well
Please show an example of data that you want to be sorted
Leave a comment:
-
@reteset, this is pretty good, do you think you could add % to the options? say at most 2 decimal places but on whole %'s no decimal.
Leave a comment:
-
Cheers, just finished moving home and haven't ported it over yet but I will be back with an example of what I'm trying to achieve
Leave a comment:
-
Originally posted by Shrek View PostCheers mate, sent you the donation but you have the note field turned off so couldn't link to this.
I shall port your code to a sample and check it out, should have made the sample first really :yes
I created that donation link in 2006 or 2007 and did not know what i am doing at the moment :o
I can make modifications on the sort function according your project requirements upon your request
Thanks
Leave a comment:
-
Cheers mate, sent you the donation but you have the note field turned off so couldn't link to this.
I shall port your code to a sample and check it out, should have made the sample first really :yes
Leave a comment:
-
Hi Shrek
When we look at the your table structure , you have used 0 as the starting index of that table
even if there is no problem with that , you know that Lua tables (numerically indexed) are 1 based
in order to implement a proper table iteration (if it will be sorted then) you should use 1 based index
if your custom control is 0 based then you can easily convert index/ID by using a +1 or -1 on the value
simply when you want to access this table by the item index of your custom control ,use +1 on that index to access table
for example you selected first item in your control , and its index is 0
when you want to access associated data on your lua table
Items[ItemSel+1]
this is a shortcut to your MapIDtoIndex() and MapIndexToID() functions
i would explain more if i could have some more info about your control
i created a detailed example ,that sorts COL1 as string ,COL2 as number
and COL3 as file size ,it also compares file size against KB ,MB ,GB etc..
you only need to align index to/from table , something like below
Code:for i = 0 ,#Items do DrawItem(Items[i+1].COL1,Items[i+1].COL2,Items[i+1].COL3) end
just use table.insert() that will automatically assign an index to associated data
in addition to these , sort algorithm does not change index , only its value
this will also avoid that index confusion
here is the sample project :Attached Files
Leave a comment:
-
Control Sorting
I have a table like so:
Code:Items = {} Items[0]={COL1="Apples",COL2=1.77,COL3="1.1 MB"} Items[1]={COL1="Oranges",COL2=1.8,COL3="56.8 GB"} Items[2]={COL1="Bananas",COL2=3,COL3="19 B"} Items[3]={COL1="Pears",COL2=7,COL3="44 MB"} Items[4]={COL1="Grapes",COL2=2.5,COL3="77 KB"}
I want to sort the table ascending or descending for alphabetic and numeric.
When the user selects the item the variable 'ItemSel' is set to the current index.
The control is redrawn every half a millisecond or on interaction (sorting/selecting) and it is darw by what is in the 'Items' table.
I need some help with the following functions:
Code:function SortAlphaAss() end function SortAlphaDec() end function SortNumAss() end function SortNumDec() end function MapIDtoIndex() end function MapIndexToID() end
There is a £20 (UK sterling) PayPay payment to anyone that can do this.Tags: None
Leave a comment: