sort files and get index from them