How to sort search results

What I’m trying to do

I’ve created a stored query, such as …

```query
path:/^TODO.md$/ line:( /\([A-Z]\)/ -/^x/ )
```

The output shows the lines in the order in which they appear in the TODO.md file.

The “(A)” code is a “priority” value, and appears at the beginning of each line. (See the todo.txt format for details.)

I’ve seen other forum posts where people want to sort the output of a search by files (i.e. if six files contain matches, sort the files by how many matches that file has, or by how recently each file was edited), but I haven’t seen anything that talks about how to sort the matched lines within each file.

In this case I’m just looking to have it sort the lines alphabetically, based on the content of each line. It seems like this should be fairly simple, but either Obsidian doesn’t provide that functionality, or it’s something that’s simple enough that nobody has asked about it, and I’m just not seeing it.

What am I missing here?

Things I have tried

```query
path:/^TODO.md$/ line:( /\([A-Z]\)/ -/^x/ ) sort by content
```

(not sure what else to try)

It looks like I’ve been looking at documentation for two different things: the “Search” core plugin, and the “Tasks” community plugin. It wasn’t obvious that the Tasks plugin is a separate thing, because its documentation looks just like Obsidian’s documentation. It might be worth updating one or the other to make it more obvious when something is part of Obsidian itself, rather than part of a third-party plugin.

Thankfully, I’m relatively new to the idea of having a “structured” TODO list that can be queried, so I’m not really invested in the todo.txt format. Mostly I just want something that’s consistent, simple, and lets me filter and sort TODO items as needed for different lists.

I’m going to keep looking at both, but so far it looks like the Tasks plugin is more “feature complete”. If it does what I need, there’s a good chance that’s what I’ll end up going with.

Unfortunately Obsidian’s embedded searches can’t be sorted. There is a request for that in Feature requests, and in the comments of the request is a link to a plugin called Query Control which enables them to be sorted. (It hasn’t been submitted to community plugins because it only exists to try to get the feature to be built in.)