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: https://www.udemy.com/course/mastering-laravel-10-query-builder-eloquent-relationships/?referralCode=C784C3DB5B8925207FCB
📲 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: https://calendly.com/codewithdary
💌 Newsletter
Sign up for my free weekly email newsletter: https://newsletter.codewithdary.com/
🔥 Resources
- Twitter: https://twitter.com/codewithdary
- Instagram: https://www.instagram.com/codewithdary
- Blog: https://blog.codewithdary.com
- Patreon: https://www.patreon.com/user?u=30307830
- GitHub: https://github.com/codewithdary
- TikTok: https://www.tiktok.com/@codewithdary
📋 Table of Content
00:00 - sortBy()
01:03 - sortByDesc()
01:41 - soryKeys()
02:08 - sortKeysDesc()
02:53 - Outro
#laravel #php #codewithdary