Sorting of lines using pointers of arrays