sort strings into 1-D and 2-D arrays