The “unique” method just returns all the unique elements. It does not perform a sort implicitly. You can invoke sort explicitly to sort the array in ascending order.
The following code works fine on EDAPlayground with VCS 2014.
module top;
initial
begin
int f[8] = {9,2,5,8,5,7,2,9};
int d[] = {1,9,12,16};
int q[$] = {2,31,5,14};
int tq[$];
int tq1[$];
tq = f.unique();
$display("%p",tq);
tq.sort();
$display("%p",tq);
end
endmodule
// output
'{9, 2, 5, 8, 7}
'{2, 5, 7, 8, 9}