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: how do i order a table in highest to lowest

Previous Thread :: Next Thread 
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
22 May 2015 11:42 PM
title


robo is love robo is life
Report Abuse
vacha is not online. vacha
Joined: 06 Jan 2011
Total Posts: 1993
22 May 2015 11:47 PM
warspykings ExtendedTable might have something like this
http://www.roblox.com/ExtendedTable-item?id=199207348


while true do the do
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
22 May 2015 11:52 PM
i remember having to do with table.unpack


robo is love robo is life
Report Abuse
Scripth is not online. Scripth
Joined: 23 Jun 2013
Total Posts: 1724
22 May 2015 11:54 PM
local tab = {1,4,5,3,2}
for i = 1,#tab do local ni = i
for i2 = i+1,#tab do
if tab[i2] > tab[ni] then
ni = i2
end
end
tab[i],tab[ni] = tab[ni],tab[i]
end
print(table.concat(tab))

need 2 do a sorting function
Report Abuse
murcury57 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
22 May 2015 11:54 PM
[ Content Deleted ]
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 May 2015 11:54 PM
If it's an array you can do table.sort
Report Abuse
Scripth is not online. Scripth
Joined: 23 Jun 2013
Total Posts: 1724
22 May 2015 11:56 PM
@cnt sort gives the table back in forms of lowest to highest, it's not what he is asking for but he could use it in the same way if he inverted and started from the back
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
22 May 2015 11:56 PM
table.sort takes a second argument.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 May 2015 11:57 PM
^
Report Abuse
Scripth is not online. Scripth
Joined: 23 Jun 2013
Total Posts: 1724
22 May 2015 11:58 PM
forgot about the comp func u could add in
i find it easier and more efficient to use a pseudo sorter than to use table.sort
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
22 May 2015 11:59 PM
lets say i have an array of tables

like

thing = {
['swag'] = {'hot'=1},
['sw'] = {'hot'=5}
}


still an array?

robo is love robo is life
Report Abuse
Scripth is not online. Scripth
Joined: 23 Jun 2013
Total Posts: 1724
22 May 2015 11:59 PM
of course
just because an array is inside of an array doesn't mean it ceases to be an array
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 May 2015 12:00 AM
Too bad it's not either of those (well, I guess "easiness" is relative)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 May 2015 12:00 AM
Robo that wouldnt be an array
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
23 May 2015 12:02 AM
ok ill make a function


robo is love robo is life
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
23 May 2015 12:04 AM
How do you plan on sorting them when they don't have number indexes?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 May 2015 12:05 AM
Yeah there is no such thing as "order" in lua's assocarrays
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
23 May 2015 12:05 AM
based on 'hot'


robo is love robo is life
Report Abuse
Scripth is not online. Scripth
Joined: 23 Jun 2013
Total Posts: 1724
23 May 2015 12:06 AM
you can sort based on strings
print('a'>'b')
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
23 May 2015 12:06 AM
But that won't change the actual position of the keys inside the table, though.
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
23 May 2015 12:11 AM
hot is equal to a numerical value


robo is love robo is life
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