Create arrays and sorting