How come you see a 4/4 war win kd in the top while you can see 5/5 and 6/7 kds behind them?

How is the ranking built on?

My kd have only lost 1 war the last 5 ages, done 5-7 wars every age and always end up behind kds with 2-3 less wars or 2 wars more but lost 4 of 9 of them.
So what is the most warring kd ranked upon?

- NW diff vs kds
- Honor diff vs kds
- Their winning score pre war?
- How short the war is?
- How much NW/ acres diff is after the war?

I don't really know the mechanics.