Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 272399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:18:34+00:00 2026-05-12T00:18:34+00:00

I think the question title is clear enough: is is possible to stable_sort() a

  • 0

I think the question title is clear enough: is is possible to stable_sort() a std::list in C++? Or do I have to convert it to a std::vector?

I’m asking because I tried a simple example and it seems to require RandomAccessIterators, which a linked list doesn’t have. So, how do I stable sort a std::list()?

EDIT: sample code that gives me an error:

#include <list>
#include <algorithm>
// ...
list<int> the_list;
stable_sort(the_list.begin(), the_list.end());

g++ gives me around 30 lines of errors (too long to paste), with some of them referring to RandomAccessIterators (and something called _merge_sort_loop). It’s a little weird, since I’ve seen some merge sort implementations for linked lists and they are pretty much ‘sequential’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:18:35+00:00Added an answer on May 12, 2026 at 12:18 am

    std::list::sort is already stable. From the standard, section 23.2.24: “Notes: Stable: the relative order of the equivalent elements is preserved.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think the title or the question is clear enough. I saw something about
I have changed title slightly because I thought this is more appropriate question. Would
Hopefully the title of my question was clear enough. Here's a really simple version
I think title of this question is pretty clear. const int WM_KEYDOWN = 0x100;
I think my question title is already crystal clear. I am invoking Process.Start() method
Well I think the title of this question is far to be clear but
I think the question title seems to explain eveything. I want to detect whether
I cannot think about a proper question title to describe the problem. Hopefully the
I think I summed up the question in the title. Here is some further
Sorry for the non-technical title, but I think it summarizes my question well. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.