I have an array of objects that I want to sort by the title, then by whether another property has a value or not. I'm trying to d3.sort
but I don't think I'm doing it correctly. I've tried:
filtered.sort(function(a, b) {
d3.ascending(a.claimed, b.claimed) ||
d3.ascending(a.title, b.title);
As well as a variation of this answer to better fit my needs, but neither of them seem to be sorting correctly. Is there something I am missing?
Here is a sample of the data in the object that I access I am working with:
author: "String"
claimed: "String" //This should be sorted first
mapClass: "String"
name: "String"
tags: "String"
thumbnail: "URL"
timestamp: "Date"
title: "String" //Then this should be second
url: "URL"