You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, October 31st 2017, 1:15pm

Sort QVector<QStringList> in alphabetical order

Hi there,
I'm stuck with a little problem:
I have a QVector<QStringList> resultVector which is composed of, let's say: ("CONTENT", "SOME STRING VALUE", "TITLE", "COMMENT").
Now I want to sort the Vector by the entry "TITLE" of each QStringList in alphabetical order, but for now I haven't figuerd out a solution.

Example:

The original Vector:

Source code

1
2
3
4
5
6
7
8
QVector(
  ("Some Content", "Another String", "Title of Entry", "Some comment"),
  ("Lorem Ipsum", "Some String", "Entrie's Title", "A comment"),
  ("Dolor", "Strings Strings Strings", "Another Title", "A commented comment"),
  ("Content of entry", "Quantum quantum quanta", "Some Title", "A comment's comment"),
  ("Foo", "bar", "Title's Title", "Comment"),
 ...
)


And how it should look like, when it is sorted by "TITLE":

Source code

1
2
3
4
5
6
7
8
QVector(
 ("Dolor", "Strings Strings Strings", "Another Title", "A commented comment"),
 ("Lorem Ipsum", "Some String", "Entrie's Title", "A comment"),
 ("Content of entry", "Quantum quantum quanta", "Some Title", "A comment's comment"),
 ("Some Content", "Another String", "Title of Entry", "Some comment"),
 ("Foo", "bar", "Titles Title", "Comment"),
 ...
)


I would really appreciate some tips for achieving this result. (I'm using Qt 5.9)