generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Alphabetize Function

Previous Thread :: Next Thread 
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
27 Mar 2013 03:06 PM
Does anybody have a function that alphabetizes objects in a table by their names? Example:

local NewTable = Alphabetize(Workspace:GetChildren())

The NewTable table would have the objects in alphabetical order. If anybody has one, I would really appreciate you giving it to me. It would save me some time on my project.
Report Abuse
BAUER102 is not online. BAUER102
Joined: 03 Apr 2010
Total Posts: 5936
27 Mar 2013 03:08 PM
http://www.roblox.com/Alphabetation-Algorithm-Mid-2011-item?id=56023168

I'm pretty sure you can do something with this.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
27 Mar 2013 03:09 PM
Doesn't table.sort do this automatically? I believe the < and > operators do work on Lua strings such that "a" < "b" == true.
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
27 Mar 2013 03:10 PM
@Dr01d

I never really looked into table.sort. I will check.

Oh, and, reported for spam.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
27 Mar 2013 03:17 PM
I just had a quick thought and this may work, although I've never used table.sort:
table.sort(workspace:GetChildren(), function (a, b) return (a.Name < b.Name); end);
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
27 Mar 2013 03:19 PM
'I believe the < and > operators do work on Lua strings such that "a" < "b" == true.'

Sorcery!
If this is true, it is epic!

However... it won't sort by second letter if the first letters are the same, unless the < and > do that.

If they don't, you need to provide a recursive function for the table.sort to sort by second letter if the first is the same, and so on.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
27 Mar 2013 03:21 PM
http://www.lua.org/pil/3.2.html
We can apply the order operators only to two numbers or to two strings. Lua compares numbers in the usual way. Lua compares strings in alphabetical order, which follows the locale set for Lua. For instance, with the European Latin-1 locale, we have "acai" < "açaí" < "acorde". Other types can be compared only for equality (and inequality).
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
27 Mar 2013 03:23 PM
'it won't sort by second letter if the first letters are the same'

OK... it does.

Nice! The more you know....
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image