Giacomo Balli profile picture
Giacomo Balli
Complex decisions. Clear thinking.

Independent advice for business owners navigating technology decisions, challenges and opportunities.
Fluent in business. Grounded in technology. Paid only by you.

Let’s Talk It Through LinkedIn

Building technology products since 2010 · 100+ apps

Sort an Array based on a JSON Object Property

This code sample will allow you to sort an array of JSON objects based on a property.

db = db.sort(function (a, b) {
	if (a.title < b.title)
		return -1;
	if (a.title > b.title)
		return 1;
	return 0;
	});

Directions:
- db is your array.
- replace "title" with the property to be used for sorting

Note:
This snippet focuses on iOS development. Make sure to verify/adapt any vendor prefixes. Back to main listing.

Published: Sun, Jan 10 2016 @ 18:50:27
Back to Blog