It appears you have an input stream that can be split into two categories - letters and numbers, and then interleave the two values.
You need multiple list (a linked list would be ideal for this data structure - the rapid append to the end that comes with them is less costly than an array backed data structure - and you don't need random access to the list) - one for each type of data you get.
You read the data in, character by character and decide which list to put the character into - the number or letter one.
Then, iterate over the length of the lists and process (print out or whatever) each one.
The code would look something like:
LinkedList<char> letters;
LinkedList<char> numbers;
for each (character in input) {
if(character is a letter) {
letters.append(character);
} else { // character is a number
numbers.append(character);
}
}
while (not(letters.isEmpty()) || not(numbers.isEmpty())) {
if(not(letters.isEmpty())) {
process(letters.poll()); // poll returns and removes the first element
}
if(not(numbers.isEmpty())) {
process(numbers.poll()));
}
}
This can be done other ways, such as interleaving the values in an array (the odd ones are letters, the even ones are numbers) and maintain multiple indexes into the array. Don't do this - it hides the intent of the code and makes it more difficult to debug later.