Re-working sort algorythm to work on Chrome.