Fixed sorting, add usage of subprocess instead of system command.