changed for loops, prints out as many copies asa desired,sorting x coordinates properly