semi sorting
working with output