How do you do it?
Here's my technique:
I used Enloop 2500mAh NiMH AA batteries, and charge them with a Maha Powerex MH-C9000 smart charger.

Since the Enloops are white, I use a black permanent Sharpie marker to number each battery. As I recondition each battery on the smart charger, I get a reading of each battery's actual capacity. This information is recorded in my battery log.
Using a log I can monitor the performance of each battery over time, and I can tell when it is time to discard a particular battery. Batteries naturally lose some capacity with time.
In order to match batteries in my lights, I can refer to my battery log. But there is a better way.
I made a chart of battery capacities and assigned a "dot" for each category. For instance:
Actual capacity
>2000 mAh = no dots
1980-2000 mAh = 1 dot
1960-1980 mAh = 2 dots
1940-1960 mAh = 3 dots
1920-1940 mAh = 4 dots
The lower the the capacity, the more the dots. These dots are maked on each battery with a Sharpie marker to indicate that individual battery's capacity.
Using this method, it is easy to match cells.
Just grab 2 or 4 batteries with the same number of dots and load them into your light.