fixed the bug using output do_sort showing wrong var