my @sorted = sort{ $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] || $a->[2] cmp $b->[2] } map { [split(',', $_)] } @$outputref;