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 » Scripting Helpers
Home Search
 

Re: How to sort a table in order of values?

Previous Thread :: Next Thread 
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
04 Jul 2014 08:12 PM
I'm dealing with a table full of variables here.

table = {playervalue1, playervalue2, playervalue3}

How am I to sort these variables?
Report Abuse
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
04 Jul 2014 08:13 PM
To clarify, I mean from greatest to lowest in value. These are numbers here.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
04 Jul 2014 08:16 PM
if Table[1] <= Table[2] then
--Code Here
end
Report Abuse
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
04 Jul 2014 08:22 PM
But is there a way to iterate through all the values? Because there's more than 2 values in this table- there's 8..
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
04 Jul 2014 08:31 PM
Use a for loop such as,
for i = 1, #Table do
end
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
04 Jul 2014 08:35 PM
table.sort(table)
Report Abuse
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
04 Jul 2014 08:45 PM
It says "attempt to compare number with nil"

agilitytable = {P1AGL, P2AGL, P3AGL, P4AGL, E1AGL, E2AGL, E3EAGL, E4AGL}

table.sort(agilitytable) --errors on this line
Report Abuse
vm9 is not online. vm9
Joined: 29 Nov 2007
Total Posts: 347
04 Jul 2014 08:52 PM
In your table, are you setting the values in the table with variables? If yes, then check to see if all of the variables actually store a value. That's about all I can help with.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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