|
| 12 Jul 2015 02:59 AM |
^ Been trying stuff for hours, and no one has been able to help. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 12 Jul 2015 03:02 AM |
| Is there anyway without using table.sort()? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|