@sorted = sort { (exists $b->{vtype_ug}||0) <=> (exists $a->{vtype_ug}||0) } sort { $a->{total_rate} <=> $b->{total_rate} } @arr;