@Kaido:
! http://i4.mangareader.net/one-piece/814/one-piece-6982909.jpg
The thing most people are missing is that, Sanji isn't supposed to be acting rationally now. He's acting in a way that befits his character. From our perspective, it seems kind of dumb for Sanji to try to get Luffy out of the way even though he should know that Luffy wouldn't just do that. But, as illustrated in the page hidden above, Sanji is not the kind of person who wants his friends to suffer or die because of him. Heck, I doubt any protagonist would, and I could think of a lot of characters who'd behave in the same way as Sanji. Imagine how he would feel if Luffy and the others died because of him. Heck, Luffy and Nami WOULD HAVE DIED if he hadn't bargained for their safety.
And no, I'm not trying to say that this is a good trait for him to keep. But this is the middle of the arc when the hero stumbles toward his darkest moment. Sanji is going to improve from this as the arc reaches its climax, because this is an actual story with character development. Sanji being written from a fan's common sense perspective instead of in a way that actually fits his character would quickly ruin the story arc, because there's absolutely no tension, absolutely nowhere for his character to go. It would just be a battle arc at that point.
Excellent post, King of the Beasts. I immensely agree. This is also why I argue that it is possible that Sanji could have given some sort of secret message to the Straw Hats. Various other characters have done stunts like this before in an improvisational fashion (Nami provoking Usopp to cause a smokescreen and faking his death in front of the Arlong Pirates, the Straw Hats giving Vivi a silent farewell by showing their X markings so that her speech wouldn't arouse suspicion from the Marines, Luffy writing 3D2Y on his arm to tell the Straw Hats to wait and train for two years before reuniting, Law passing a note to Chopper while they were imprisoned in Punk Hazard near the villains, etc.), and Sanji is known for this type of thing with his Mr. Prince antics of cunningly messing up the bad guys' plans on the spot.
However, that does not mean that the scene Oda wrote was bad storytelling. Because the message he was trying to illustrate for us was a mix of Sanji being surrounded by overwhelming odds AND his characterization of traditionally acting selfless. We weren't just supposed to see how the situation itself is factually impossible for the Straw Hats to solve, but how the Vinsmokes literally broke Sanji's resolve. He was both vocally and actively fighting back against his captors at first. But after seeing how his actions got Cosette beaten and how we have visually seen Sanji trembling around his family (such as when Ichiji and Niji arrived at the docks), he lost his will to have faith in relying on anyone else and his natural instincts to instead sacrifice himself kicked in. Couple that in with Sanji having flashbacks to his father and brothers constantly reprimanding and bullying him over how his aspirations to cook like his mother are illogical and wasteful despite Sanji having so much pride in that passion, which connects to his dream of finding All Blue despite it being a fairy tale. Had Luffy and Nami caught up to Sanji before Cosette beaten up, I think that Sanji would have tried something different than pull the facade and beat up Luffy by having faith in his crew, because they've been through thick and thin in overcoming insurmountable obstacles like declaring war against the World Government in Enies Lobby. But after everything he went through, it makes complete sense character-wise why Sanji did what he did.
So all in all, this is all part of a character development journey for Sanji to appreciate his worth and what he contributes to the crew, his new family. This sort of thing has happened with everyone else Luffy has helped, and I doubt that Sanji is going to be the exception just because.