of     1   

bojigglesmister2
#184543800Monday, February 29, 2016 7:09 PM GMT

Lets say I have a table like .... strings = {"Cantelope", "Bear", "Apple"} How would you sort that in alphabetical order?
ThomasChabot
#184543854Monday, February 29, 2016 7:10 PM GMT

Don't think there's some provided method for it but its easy enough to do on your own Look up bubble sort You'd also need to compare strings which I haven't done too much in Lua so I'll leave that to someone else :o http://www.roblox.com/Gretzky-item?id=369637787
bojigglesmister2
#184544008Monday, February 29, 2016 7:14 PM GMT

bump
bojigglesmister2
#184544176Monday, February 29, 2016 7:19 PM GMT

"Don't think there's some provided method for it but its easy enough to do on your own" its table.sort dude, thanks for the false info
ThomasChabot
#184544260Monday, February 29, 2016 7:22 PM GMT

Oh gg Then y r u asking if there's a method for it olol http://www.roblox.com/Gretzky-item?id=369637787
HarrySnotte
#184544440Monday, February 29, 2016 7:27 PM GMT

This isn't a hard question, but a tough one because as there is no specific method for this, you'd have to take a huge way around to do this... local alphabet = {"a", "b", "c", ... , "z"} --finish this off plz :3333 local strings = {"Cantelope", "Bear", "Apple"} local orderedstrings = {} function OrderStrings(t, n) --t is the table of strings, n is the position of the letter to be checked local original = t local ordered = {} for i = 1, #alphabet do local lettertable = {} for i2 = 1, #t do if t[i2]:sub(n, n) == alphabet[i] then table.insert(lettertable, t[i2]) end end lettertable = OrderStrings(lettertable, n+1) table.insert(ordered, lettertable) end return ordered end orderedstrings = OrderStrings(strings, 1) --this would return a lot of tables inside other tables, therefore, I'm going to unpack it into one solid table: function UnpackTable(t, OrderedStrings) local ta = OrderedStrings for i = 1, #t do table.insert(ta, UnpackTable(t[i], OrderedStrings) end return ta end local orderedstrings = UnpackTable(orderedstrings, {}) I wrote this real quick, so it is highly possible that there are a lot of mistakes in here, try to understand what I did and if there are questions, feel free to ask :)
128Gigabytes
#184544600Monday, February 29, 2016 7:31 PM GMT

@Harry table.sort
HarrySnotte
#184544638Monday, February 29, 2016 7:32 PM GMT

Yeah, I might just have written that bs for nothing, never heared about table.sort though...
digpoe
#184544696Monday, February 29, 2016 7:33 PM GMT

table.sort (by default) sorts using the operator (i forget which one), and when applied to strings it will compare them alphabetically. -Become a programmer, they said. It'll be fun, they said.
ThomasChabot
#184544804Monday, February 29, 2016 7:37 PM GMT

Its more fun in languages like Java where u don't have autosort111 But ye if u have table.sort then just use that but u miss out on the fun :( http://www.roblox.com/Gretzky-item?id=369637787
128Gigabytes
#184544896Monday, February 29, 2016 7:40 PM GMT

This is what table.sort does local function tableSort(array, sort) local sort = (sort or function(x, y) return (x < y); end) for x = 1, #array, 1 do for y = 1, #array, 1 do if (sort(array[x], array[y])) then array[x], array[y] = array[y], array[x] end end end return (array); --[[table.sort doesn't return the array.]] end

    of     1