robomax11
|
  |
| Joined: 07 Jul 2011 |
| Total Posts: 6828 |
|
|
| 22 May 2015 11:42 PM |
title
robo is love robo is life |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 22 May 2015 11:56 PM |
| table.sort takes a second argument. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 May 2015 12:00 AM |
| Robo that wouldnt be an array |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 23 May 2015 12:04 AM |
| How do you plan on sorting them when they don't have number indexes? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 23 May 2015 12:06 AM |
you can sort based on strings print('a'>'b') |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 12:06 AM |
| But that won't change the actual position of the keys inside the table, though. |
|
|
| Report Abuse |
|
|
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 |
|
|