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: Organizing numbers greatest to least!

Previous Thread :: Next Thread 
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Jul 2015 02:59 AM
^
Been trying stuff for hours, and no one has been able to help.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
12 Jul 2015 03:00 AM
local Numbers = {100, 42, 11, 4421, 9}
table.sort(Numbers, function (x, y) return x < y; end)

for i, v in next, Numbers do
print(v)
end

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Jul 2015 03:02 AM
Is there anyway without using table.sort()?
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
12 Jul 2015 03:04 AM
why wouldn't you want to use table.sort?
Report Abuse
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Jul 2015 03:05 AM
How would I table.sort() this? The 'Item.rap'.

for _, Item in pairs(hatData) do
table.insert(Items, {Item.id, Item.name, Item.rap, #Item.userAssetId})
end

for k, v in pairs(Items) do
table.sort(Items, function(a, b) return a > b end)
end
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
12 Jul 2015 03:07 AM
try this:

for _, Item in pairs(hatData) do
table.insert(Items, {Item.id, Item.name, Item.rap, #Item.userAssetId})
end

table.sort(Items, function(a, b) return a.rap > b.rap end)
Report Abuse
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Jul 2015 03:09 AM
Nothing. That doesn't even make sense since, a.rap and b.rap aren't defined correctly.
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
12 Jul 2015 03:12 AM
oops, wasn't looking closely

for _, Item in pairs(hatData) do
table.insert(Items, {Item.id, Item.name, Item.rap, #Item.userAssetId})
end

table.sort(Items, function(a, b) return a[3] > b[3] end)

or even better:

for _, Item in pairs(hatData) do
table.insert(Items, {id = Item.id, name = Item.name, rap = Item.rap, userAssetId = #Item.userAssetId})
end

table.sort(Items, function(a, b) return a.rap > b.rap end)
Report Abuse
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Jul 2015 03:16 AM
THANK YOU! I CAN FINALLY SLEEP! The first one worked. I was over-complicating the code. Shows how much sleep is important.
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