Need Help Creating SATA Power Cable for Lenovo C540 AiO
https://en.wikipedia.org/wiki/Molex_connector
Why does the SATA power connector have so many pins?

black = ground
red = +5v
yellow = +12v
the answer is basically in your pics.
for white molex, the black next to the yellow is the ground for the +12vdc circuit.  And the black next to the +5vdc red is ground for that.
With the black SATA connector, black between yellow and red goes to the yellow +12vdc circuit.  The gray sata wire, on the sata power connector, is either a hard drive spin up signal wire or 3.3vdc power, there's no significant current on the gray wire so it shares ground with the red +5vdc.

Can anyone confirm that I can connect either black to either black? I don't really understand why they don't just put them in the same order on both ends to avoid confusion.

The SATA power connector has 15 total pins, but you can't put X wattage through one 1mm wide pin in the connector so there are numerous pins to provide the area needed given the form factor of that connector.
If you criss cross the ground wires then what would happen?
I don't know I can only speculate.
But in electrical engineering terms would high current +12vdc return to the power supply on what would be the +5vdc rail before ground DC ground becomes common with the PSU? I think if you answer that question then you would know for sure if criss crossing the ground wires is something not to do.  If you're connecting just one hard drive, especially an SSD which uses like 2 watts, I doubt there would be any harm.  The worry would be if some high power device was being powered.  In any case, I would not criss cross those two black grounds and given what I described above hopefully it's now clear that if your messing with it there should be no reason now you would end up criss crossing the grounds.
do this: