I'm pretty sure that it takes at most N-1 weighings to determine the relative weight of every ball.
As an example, let's say N=8, with balls B1-B8.
We can start by comparing groups of two.
B1 & B2
B3 & B4
B5 & B6
B7 & B8
Now, there are only two possible results from these tests. Either they don't weigh the same, or they do. If the balls are of different weights, we place them into the "heavy" pile or "light" pile accordingly, easy-peasy.
If the balls DO weigh the same, then we just place that group aside for a minute.
Once this first trial is complete, we've done 4 weighings. If the balls are all different, we're done.
If, on the other hand, some or all of those weighings led to the balls being equal, we do another round. I'm going to assume that all of the weighings came up equal, to pursue the worst case scenario. For the next round, we combine the groups from the first round, and weigh them against each other.
B1+B2 vs B3+B4
B5+B6 vs B7+B8
After 6 weighings, we're at the same place as after the first round. If the weights were different, the answer is obvious. If they weighed the same, we do one more trial.
B1+B2+B3+B4 vs B5+B6+B7+B8
And now we know for sure which balls weigh what, in the worst case, with 7 weighings.
(And in all honesty, if the problem states that we KNOW there is at least one ball with a different weight, that last weighing is unnecessary. We wouldn't necessarily know which group was which weight, but we'd be able to separate them.)