I'm testing out a name change with Agent, my browser.
So if it doesen't work, I'm that last guy robic.
-------------------------------------------------------------
I just want to post some follow up comments for you ...
P/001¤5.08¤Order Requisition.¤-¤Y¤3 Years¤Accounts Admin¤¤
P/002¤5.07¤Request for Subcontractor Approval¤Jul-98¤Y¤3
Years¤Purchase Control¤P_002.dot¤
P/003¤5.07¤Supplier Quality System Assessment
Questionnaire¤Apr-03¤Y¤3 Years¤Quality Control¤P_003.pdf
the above information is split using ¤ into a nested array forming a
table
For best results try not to think in terms of "nested".
What you have is an array of records (or structures).
Thats what a "table" is.
i want to be able to sort the columns e.g the data file is currently in
order by the first column (Form Number) i want to be able to sort by
Title instead (Col 3) or Ref (Col2)
It's better thought of as rows and fields,
"columns" denote numeric, fixed width common type, byte oriented
ordinals.
ive seen the links you have given me above but i cant get my head round
on how im gonna impliment it into my code, seem to understand working
examples better that normal help examples
note. i dont want to resort the data in the file just the data in the
array so when it is outputed to screen its in the selected order
Sorting large amounts of data does not mean "moving" that data around.
Having a pre-defined pointer (in C) or a reference (in Perl)
means you don't actually "move" the data but just collect the pointer
or reference in a different way so that when you want to access
that data all you have to do is to access the arranged pointers
or references to print the real data in a sorted order.
In database terms, this is called an index. So the "real" data
stays put and never moves. You just manipulate arrays of references
that mirror how the data relates to itself.
Comparing data elements in my example, just manipulates/re-arranges
the containing array of references "to" the data.... it does not
actually move the data around. Thats why its so fast.
note2. $TempData[0][x] $TempData[1][x] do not want to be sorted as they
contain the table headers & other setting/info i require for the page
formatting. i want to sort between $TempData[2][x] and
$TempData[$TempData[0][0]][x]
$TempData[0][0] being the number of rows
It looks like you have a header you want to embedd in the table
itself. On the array sort example I gave you above, I purposely
left out the fact that you could have sorted the containing
array of references, @TempData starting and ending on any element
like this:
@TempData[$start..$end] = sort {$a->[$somefield] cmp $b->[$somefiled]}
@TempData[$start..$end];
Instead, make a containing header, that holds all the info on
the "table". Its not necessary to track the number of fields
as @{$aref}-1 will give the last element for boundry checking.
A known element of the header could be a "reference" to the
actual data array so that if you write a specialized function to do
your sorts, just pass a reference to the containing header,
along with info on the prioritized, variable number of fields
you want to sort. Really though, most containing headers
should be hashes so you can easilly access the "named" table.
- header as an array:
@HeaderArray = ();
$HeaderArray[0] = "Table Name";
$HeaderArray[1] = \@TempData;
$HeaderArray[2] = another known important table info
.... then calling MySpecialArrayHeaderTableSort (\@HeaderArray,...);
- header as a hash:
%HeaderHash = ();
$HeaderHash{'TableName'} = "Table Name";
$HeaderHash{'Data'} = \@TempData;
$HeaderHash{'ExtraInfo'} = another known important table info
.... or calling MySpecialHashHeaderTableSort (\%HeaderHash,....);
The "header" container now contains all the info.
You could actually now control a group of variable tables via
another container:
@AllTables = (\@HeaderArray1, \%HeaderHash1,....);
This is just an array of "references".
Hope this helps you. I didn't go into a much more complicated
area called compound structures.
Its always a good idea to keep a greater than 2 dimentioned
array "homogenous" and NOT try to imbedd anything which
makes it "non-square". Always factor out to a new level
if that is what you need to do.
Let me know if you need any more help.
gluck