seperated sort into function
added concatenate function