Based on the requirements (
"Sort the unsorted elements and square the elements in it"), the output you are getting is correct.
If you really wish to obtain a
sorted list of squares, then you have first to generate a list of squares and then sort it.
Try
lin = list(map(int,input().split()))
lsq = ([x*x for x in lin])
lsq = sorted(lsq)
for sq in lsq:
print(sq, sep=" ")