4 Must Know Methods to Sort Your Collections by Keys - Mastering Eloquent & Collection Methods

In this tutorial, we’re going to cover a couple of pretty interesting methods that are useful for sorting collections based on their keys. Specifically, we’ll be taking a look at the sortBy, sortByDesc, sortKeys, sortKeysDesc, and sortKeysUsing methods, and how they can be used to sort collections in different ways. Whether you need to sort a collection by a specific key, sort a collection based on the order in which the data was added, or sort a collection in reverse order, these methods have got you covered. 📚 New Udemy Course If you’re looking to level up your Laravel skills? My new course “Mastering Laravel 10 Query Builder, Eloquent & Relationships“ is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: 📲 Let’s plan a meeting Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews, or a coaching session for Laravel: 💌 Newsletter Sign up for my free weekly email newsletter: 🔥 Resources - Twitter: - Instagram: - Blog: - Patreon: - GitHub: - TikTok: @codewithdary 📋 Table of Content 00:00 - sortBy() 01:03 - sortByDesc() 01:41 - soryKeys() 02:08 - sortKeysDesc() 02:53 - Outro #laravel #php #codewithdary
Back to Top