Is the numerical item in your list the cid value?
To state again what has been said before: cids aren't meant to be in any particular order. Open 3 cons, close 2 cons, open 1 con - the cid of the last one has not to be 4 (or 2). A cid is nothing but an unique ID per connection. (with cons I mean "status windows".)
I don't understand why you want to "clean up the cids" - this could break scripts who refer to a particular cid.