![]() |
|
C++ : sorting a vector |
Trent Gamblin
Member #261
April 2000
![]() |
See, you don't admit you're wrong because you WERE and ARE wrong. What I showed in that code is how to produce a stable sort using std::sort. Geeze man, get over yourself.
|
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Stas B. said: I'm not mad at you or anyone.
Quote: you need three spoons of sugar
Quote: I couldn't care less
Quote: I will keep calling you on your bullsh*t You could have fooled me. They all watch too much MSNBC... they get ideas. |
Trent Gamblin
Member #261
April 2000
![]() |
The only thing I did wrong in this thread is fail to explain that you don't always want or need a stable sort. That was an accidental omission. Feel free to point out any other "nonsensical bullshit".
|
Stas B.
Member #9,615
March 2008
|
Trent Gamblin said: See, you don't admit you're wrong because you WERE and ARE wrong. What I showed in that code is how to produce a stable sort using std::sort. Geeze man, get over yourself.
Are you honestly an idiot? Arthur Kalliokoski said: You could have fooled me.
That's my default manner of speaking. Shame on me. |
Trent Gamblin
Member #261
April 2000
![]() |
<facepalm> 1) The sort you used first was completely different from mine. Don't compare apples and oranges. YOUR results are wrong. It's supposed to sort them as integers. 2) Try putting MINE first, not after you've fucked up the arrays. It WORKS. Numb nuts.
|
Audric
Member #907
January 2001
|
For what it's worth, I find the documentation of STL's sort() very ambiguous on how the compare function should behave. |
Dizzy Egg
Member #10,824
March 2009
![]() |
Finally an exciting thread! Come on Trent destroy him DESTROY!!!!
---------------------------------------------------- |
Trent Gamblin
Member #261
April 2000
![]() |
I think I just did that. EDIT: And I appologize for being a prick. I should have corrected you in a more calm manner
|
axilmar
Member #1,204
April 2001
|
The function std::sort does not guarantee the preservation of order of equivalents; std::stable_sort does have that guarantee. |
Stas B.
Member #9,615
March 2008
|
Audric said: For what it's worth, I find the documentation of STL's sort() very ambiguous on how the compare function should behave. That's actually true. Thankfully, it comes with an example. But to be honest, that's not even the point. The point was that the stability depends on the algorithm, not on the comparison function. Granted, it won't work if you don't provide it with the callback it expects, but that's obvious and besides the point. Trent Gamblin said: 1) The sort you used first was completely different from mine. Don't compare apples and oranges. YOUR results are wrong. It's supposed to sort them as integers. 2) Try putting MINE first, not after you've fucked up the arrays. It WORKS. Numb nuts. I honestly don't understand what you're talking about. I hope you're just trolling... Correct me if I'm wrong, but you said that this callback: bool compare_foos(Foo *a, Foo *b) { return a->bar <= b->bar; }
Can be used with std::sort to achieve stable sorting. Come on, guys. You're better than that. Somebody take a serious look at it and explain to him why he's wrong. [EDIT] To be fair, this example isn't even mine. It's from the STL documentation that demonstrates stable sorting. I just replaced their callback with yours. |
Matthew Leverton
Supreme Loser
January 1999
![]() |
The std sort is not stable when two elements are equal. How is that up for discussion? |
Trent Gamblin
Member #261
April 2000
![]() |
Ok, I'm wrong. I had my definitions wrong. By 'stable sort' I actually meant a sort that will return the same results every time. Hell, I may even be wrong about that, but I remember having different results returned when using < and not <= when implementing A* one time. So it's not a stable sort, and I'm not even sure that < will return different results at any time. I was sure that was the case though. Anyway, appologies for posting incorrect information.
|
Stas B.
Member #9,615
March 2008
|
Trent Gamblin said: Ok, I'm wrong. I had my definitions wrong. By 'stable sort' I actually meant a sort that will return the same results every time. Oh. In that case, I'm sorry, Trent. I didn't realize we were actually talking about completely different things! I'll just leave this here: Trent Gamblin said: Trent Gamblin: Yeah, exactly, and that's exactly what the '=' does. Think about it.
Trent Gamblin said: YOUR results are wrong. It's supposed to sort them as integers. 2) Try putting MINE first, not after you've fucked up the arrays. It WORKS. Numb nuts.
Implying my example gave you different results every time? |
Trent Gamblin
Member #261
April 2000
![]() |
Ok dude, think what you want. I don't really care. If you can't accept an appology then you don't deserve one.
|
Stas B.
Member #9,615
March 2008
|
Trent Gamblin said: Ok dude, think what you want. I don't really care. If you can't accept an appology then you don't deserve one. Oh, come on. Nobody can be that thick. You think I need your apologies? Seriously? It's just about being a decent person. How decent is it when you're outright lying in your apology? It's not about what I think. It's about what anybody who reads your posts thinks. Maybe I sound like a jerk, but at least I'm honest. |
Trent Gamblin
Member #261
April 2000
![]() |
I was being completely honest. I think you just have a hard time seeing any merit in anyone but yourself. You win on technical terms, but I have no doubt that I walk away the better person.
|
Stas B.
Member #9,615
March 2008
|
Trent Gamblin said: I was being completely honest. I think you just have a hard time seeing any merit in anyone but yourself. You win on technical terms, but I have no doubt that I walk away the better person. You started flaming me with personal attacks as a response to my posts that talked exclusively about the technical matter at hand and not about you. After realizing you were wrong, you wrote a phoney apology where you lie about mixing up the definitions, as evident by the fact that some of your earlier posts make no sense in this new context and the fact that you've confirmed that we are in fact talking about the same thing. If you think you walk away the better person, I feel sorry for you. |
Trent Gamblin
Member #261
April 2000
![]() |
I was right about one thing: asshat. And that's not a compliment even though you wear it like a badge of pride. Don't feel sorry for me, my shit has been sorted for a long time now. Good luck with yours.
|
Dizzy Egg
Member #10,824
March 2009
![]() |
Your imlplying that Trent is thick? Oh dear oh dear, a LOT to learn then Stas B.
---------------------------------------------------- |
GibbSticks
Member #14,193
April 2012
![]() |
Another thread completely destroyed because of petty arguments, sigh
C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
bamccaig
Member #7,536
July 2006
![]() |
I'm a little confused about this... It sounds like stable_sort is designed to work the way Trent's revision is without explicitly coding the comparer that way. So wouldn't the correct way to achieve a "stable sort" be using stable_sort instead of altering the behavior of your comparer?
-- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Stas B.
Member #9,615
March 2008
|
bamccaig said: So wouldn't the correct way to achieve a "stable sort" be using stable_sort instead of altering the behavior of your comparer? Yes. The only way if you want to use the STL sort functions. |
bamccaig
Member #7,536
July 2006
![]() |
@Stas B.: For what it's worth I don't think that you were being an asshat in this thread either... -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Trent Gamblin
Member #261
April 2000
![]() |
Stas B.
Member #9,615
March 2008
|
Trent Gamblin said: Let's rewind and see who threw the first punch... Stas B. said:
But it was. |
|
|