In c++, all a sort operation needs is a lessThan function. Complex sorts are EASY:

struct AnalyzerJobs_lessthan
{
    bool operator()(const AnalyzerJob* left, const AnalyzerJob* right) const
    {
        assert(left ->psq_->second && left ->psq_->second->p_shared_aps_ && left ->psq_->second->p_shared_aps_->p_ad_);
        assert(right->psq_->second && right->psq_->second->p_shared_aps_ && right->psq_->second->p_shared_aps_->p_ad_);

        // Primary sort
        // Critical jobs first
        // If only one is critical, it wins.
        if (left ->psq_->second->p_shared_aps_->bCriticalAnalysisNeeded() != right->psq_->second->p_shared_aps_->bCriticalAnalysisNeeded())
            return left ->psq_->second->p_shared_aps_->bCriticalAnalysisNeeded();

        // Secondary sort
        // If only one has never been analyzed, it wins.
        if (left->psq_->second->p_shared_aps_->bAnalyzed() != right->psq_->second->p_shared_aps_->bAnalyzed())
            return right->psq_->second->p_shared_aps_->bAnalyzed();

        // Tertiary sort by reverse timestamp of last analysis.
        double lefttime  = left ->psq_->second->p_shared_aps_->analysis_finished_timestamp_;
        double righttime = right->psq_->second->p_shared_aps_->analysis_finished_timestamp_;
        return (lefttime > righttime);
    }
};

You’d think JavaScript would keep that battle-tested methodology, but they decided it would be better to expect a result from the sort function of [ -1, 0, 1 ]. I’m assuming so they can eek out a bit of performance when sorting arrays that have a large number of “equal” items. Seems an outlier case to optimize for, but it probably puts it on some slightly higher score on some manic benchmark.

So for even the simplest sort, you have to do this stupidity:

myArray.sort(( a, b ) => ( a.value > b.value ? 1 : -1 ));

It seems to work as long as the sign is right, so this is also possible:

myArray.sort(( a, b ) => ( a.value - b.value ));

Also, remember that JavaScript provides all kinds of “helpful” dangerous ugly default conversions. Cest la vie. I have to remember though – I’ve used c++ style comparisons in JavaScript sort functions more than once, and that shit don’t fly. ok byeeeee!

Boost 1.77 is working well with it, and I’ve fully migrated to boost::json, which is working out great. The straw that broke the camel’s back was map.contains(), lolz. I was ready! I feel like I’ve had a hot bath. Nice.

Bash is the worst pile of anti-patterns and hacked up bullshit, but what would you expect from something that’s been our emergency-room band-aid for as long as we’ve been alive? This is just a reminder, for your career’s sake, to NOT make it one of your “specialty languages”. Learn what you have to. And double down on a modern, sane scripting language. I’ve tooled up node to do all things command-line, I recommend you do the same – but even writing little Java or C++ command-line apps is better than letting bash poison your brain! Just say no. And some day, our great-great-grandchildren will have a replacement. No, not another sh variant. A true sane modern programming language. okbyeeee!

Hate of the day: I love how [rm -f ] “fails” (non-zero error code) but [mkdir -p …] “succeeds”, and there is no [mv -f …]. The Unix philosophy: do one thing, and do it well, but always slightly differently than anyone else would have done it. Sure it’s bizarre bazaar chaos, but it’s “beautiful”. Ummmm…. no, fuck you, I don’t want to memorize your chaos.

UPDATE: Dude. In my defense I was in pain and jacked on meds when I wrote this, haha. Step away from the oxy, take less Adderall… calm ye self down. “Whatever Works”.

UPDATE 2: Yeah, the horror is real. Yet another damning example of why, for your career’s sake, you should focus on a real scripting language and not (ba)sh’s arbitrary stupidity.

The thread_local scope tells the compiler to create one unique version of a variable per thread. Then you can access it without worrying at all about in what thread you are. (Grammar Nazis, help me out here. I think I got that right…) It is absolutely genius for making multi threaded programming that much easier. W00t.

UPDATE: of course, every razor blade comes with its share of nicks. In this case, the expectation that different objects in the same thread would still have different thread_local members. Nope! Vet your ideas before you change to this scope too fast! Me, I’m all better now, and still love it. Good luck girls and boys.