An Index can Order, Filter, and Search
Think of a physical, book-loaning library. It's a big room of books, but it's organized by the Dewey Decimal System (DDS). The DDS is sorted first by topic, and then by author within topic. Each book then has an index in the back, which is an alphabetical list of topics with page numbers.
In computer science, both the book index and the Dewey Decimal System are called "indices" (some say indexes). That is, they provide a way for you to find quickly by some category (topic, author, etc) the information that is relevant to you.
Database (computer science) indices are similiar in concept to both those examples, but the math is very different, click at your own risk.
But what you should notice, is that the index is already sorted by topic and already sorted by author. The fundamental code that provides the index provides the search, sort, and filter mechanisms. The request (the query) is what changes: