Just a quick Sunday-evening post because I was doing this with my Crispy M&Ms and I thought, "That's probably something to go on the autism blog". It's something I do constantly with anything that's a mix of colours (and always have done). M&Ms, Skittles, etc. and it is part of being autistic.
I like to know how many of each colour I have, then I work out which colour has the fewest, so I give eating priority to those of other colours that exceed the number of the colour with the fewest, so there's the same number of each colour. Then I'll eat either one or two of each colour so that by the time I've eaten one or two of the final colour there's still the same number of each colour.
It's partly a flavour thing when it comes to Skittles - orange is my least-favourite colour, so I eat all the orange ones first, then the blackcurrant ones, then one each of lemon and lime together, then finish with strawberry, which is my favourite. With M&Ms flavour isn't an issue, but I still go for the orange ones first, then the brown ones, then usually red, yellow, green and finally blue (though for some reason today I did it the other way round - I don't know why and now it's bugging me). If I'm in a situation where I can't count them, line them up and so on it does stress me out. That situation's most likely to occur when I'm driving, although as Gideon doesn't particularly like Crispy M&Ms we don't tend to get them, so that scenario doesn't come up very often. If I'm munching on them while driving alone, I just have to grit my teeth and put up with it because there's not much I can do.
On its own it's not a harmful behaviour so I'm not going to do it just because it's considered a bit "odd" or in order to seem NT or anything like that - I don't modify my behaviour in order to "pass" as NT because I am autistic and don't want to be anything else. However, I'm far more likely to engage in it rigidly and inflexibly when I'm stressed, so if I'm being really strict about it, it's usually an indicator that something is off and that I need to watch myself in case my other OCD behaviours kick in, behaviours that can cause actual problems.