I wouldn't go by the dorsal rays to tell the difference, not very reliable IMO...the best way to tell is by the pink/red belly. If they have it, it's definitely female, but like Freddy said, they don't always show the pink/red coloration.
Best way is to check the length of the fins. Males have longer showier fins than the females. If you are looking at a group in an lfs.....and you want a male and female pair.........watch the tank for a good while and look for two that are hanging out together. Compare their fin length, look for the red/pink belly and also, the males black spot tends to be more "solid" than the females...though I have seen some females with nice dark spots.
If they are near to spawning it's really easy to tell...besides the red belly....the appendage that protrudes during spawning is different on the male and females. The female's ovipositor is more blunt and squared, where the male's ...um....appendage, whatever you would call it...lol.....is very pointy and slim.......
Two pics of my males.......
Two females.......the first pic is just as she is laying eggs....
This also works when trying to sex bolivian rams....I noticed at an lfs recently ...3 bolivian rams and I could tell that one was male and the other two were females, by the shape of the "appendage"......I was POSITIVE about it and if I had a tank for them I would have taken a male and female home with me !