PDA

View Full Version : How Do I Sort Table Before Populating Tree?


Robert29b
12-22-2008, 10:21 AM
Need help sorting table

folderbrowse1 = "d:\\playlists\\";
M3U = File.Find(folderbrowse1, "*.m3u", true, false, ShowSearchProgress, nil);
for i,v in M3U do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
tblNodeData = {};
tblNodeData.Text = name;
tblNodeData.Data = v;
Tree.InsertNode("Tree1", "3", tblNodeData);
end

How do I sort this table before inserting into the tree object?

Imagine Programming
12-22-2008, 11:01 AM
Table.Sort (
table SourceTable,
function Compare = nil )



Description
Sorts the items of a numerically indexed table.

Parameters
SourceTable
(table) The table to sort.

Compare
(function) An optional comparison function to use while sorting the table. The function should be able to compare two values and return true if the two items are already sorted, or false if the items need to be swapped. If no function is specified, the less than operator (<) will be used to sort the items.

Returns
Nothing.


Source: AMS Help File