DListView Sorting Question

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 :confused:


[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


This is the function below


function PANEL:SortByColumns( c1, d1, c2, d2, c3, d3, c4, d4 )

	table.Copy( self.Sorted, self.Lines )
	
**Line 514 ---->**	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

table.sort

Has anyone ran into this problem when calling the “SortByColumns” function instead of using the “SortByColumn” function?

You’re using it wrong, You think lua is magic code.

It’s not even his code.

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.