• DListView Sorting Question
    5 replies, posted
I was wondering if there is a way to sort columns by using more than one column? The SortByColumn uses one column to sort the following things in the table, but I was wondering how I could sort it using two columns that has integer values in them. I found out that there was SortByColumns and I tried it out.. Gives me an error I can't work with :/ [code][ERROR] lua/vgui/dlistview.lua:514: invalid order function for sorting 1. sort - [C]:-1 2. SortByColumns - lua/vgui/dlistview.lua:514 3. func - lua/autorun/client/cl_ncvote.lua:44 4. unknown - lua/includes/modules/net.lua:31 [/code] This is the function below [code]function PANEL:SortByColumns( c1, d1, c2, d2, c3, d3, c4, d4 ) table.Copy( self.Sorted, self.Lines ) [B][U]Line 514 ---->[/U][/B] table.sort( self.Sorted, function( a, b ) if (!IsValid( a )) then return true end if (!IsValid( b )) then return false end if ( c1 && a:GetColumnText( c1 ) != b:GetColumnText( c1 ) ) then if ( d1 ) then a, b = b, a end return a:GetColumnText( c1 ) < b:GetColumnText( c1 ) end if ( c2 && a:GetColumnText( c2 ) != b:GetColumnText( c2 ) ) then if ( d2 ) then a, b = b, a end return a:GetColumnText( c2 ) < b:GetColumnText( c2 ) end if ( c3 && a:GetColumnText( c3 ) != b:GetColumnText( c3 ) ) then if ( d3 ) then a, b = b, a end return a:GetColumnText( c3 ) < b:GetColumnText( c3 ) end if ( c4 && a:GetColumnText( c4 ) != b:GetColumnText( c4 ) ) then if ( d4 ) then a, b = b, a end return a:GetColumnText( c4 ) < b:GetColumnText( c4 ) end return true end ) self:SetDirty( true ) self:InvalidateLayout() end[/code]
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index409f.html"]table.sort[/URL]
Has anyone ran into this problem when calling the "SortByColumns" function instead of using the "SortByColumn" function?
[QUOTE=kaos2100;38624821]Has anyone ran into this problem when calling the "SortByColumns" function instead of using the "SortByColumn" function?[/QUOTE] You're using it wrong, You think lua is magic code.
[QUOTE=NinjaS;38626844]You're using it wrong, You think lua is magic code.[/QUOTE] It's not even his code.
[QUOTE=NinjaS;38626844]You're using it wrong, You think lua is magic code.[/QUOTE] You are retarded just get out of my thread. You obviously think LUA is magic code since you think I wrote this when its part of gmod. This is given by Garry in lua/vgui/dlistview.lua and I'm just stating that it doesn't work when I call this function. You would understand something if you read the OP, but obviously you are just butthurt getting rated dumb. I rated you dumb because of your half-assed response "table.sort". I know what it is and how it works. You seem to think yourself as a LUA king or whatever so please give me your insight to why it won't work. Otherwise just crawl back into your cave.
Sorry, you need to Log In to post a reply to this thread.