new sorting script (HIGHLY EXPERMINTAL, DONT COPY ANY OF ITS CHANGES)