Search⌘ K
AI Features

Overview of Search & Sort

Explore how to implement search and sort functionalities in a Kotlin-based Android app to help users find relevant information quickly. Understand using Kotlin's sortedBy and filter methods to manage collections effectively and enhance user experience on mobile devices.

We'll cover the following...

Mobile devices usually have small screens in comparison to laptops, which means it’s harder to present and work with big amounts of data on mobile devices. To address this, we are going to implement search and sort functionality to help the user find relevant information faster.

Most of the actions related to the screen are placed in the Toolbar menu, and that’s where we are going to put the search icon (left image) and the sort menu item (right image).

To implement the sort logic, we are going to take advantage of Kotlins sortedBy method.

To learn more about collection ordering, navigate to Kotlin documentation.

For the search functionality, we are going to simply filter the list by title relying on the String.contains method.

To learn more about collection filtering, navigate to Kotlin documentation.

It’s strongly advised that you familiarize yourself with these methods and refresh your knowledge working with collections in Kotlin before proceeding to the next lesson.

To learn more about search patterns on mobile devices, check out the material design search case study.