please put your code between <code> </code> tags, like this
my %hash=(inst => { dept1 => { rollno=> { [name,marks], [name1,marks1]
+, }, inst2.... });
do you want to sort by inst, dept, marks?
I think we need a little more description of your structure, rollno is that a constant, or is it a value like isnt or dept1? why are the marks in array refs inside a hashref, which wouldn't work if you had an odd number of names. You would want them either in an arrayref like
rollno => [ [name, marks], ... ] or in a hashref like
rollno => { name => marks, name => marks, ... }.
And as mentioned in another response, supply what your data would look like sorted.