No, sorry, this is not about the song. But well, while you’re all here, why not start it in the background, and continue reading…? 😅

CONFLICT (some-branch): Merge conflict in some/

Over and over again, I encountered merge conflicts due to several people adding stuff to some kind of list by simply appending whatever they had to add right to the end. Doing that, obviously, will break the automatic merge process of either Git or your IDE, or whatever other tool/context there is.

Alphabetize All the Things

But, you know, inserting the new thing where it belongs according to the alphabet would most probably auto-resolve 90% of all those merge conflicts!

Find All the Things

Also – and I find this equally important to not having to waste five minutes over and over again by reading through two (or more) commits, the respective results after them being applied, deciding on the desired combined result and then resolving the merge by hand – sorting things alphabetically, quite often makes a whole lot of sense, in terms of readability/discoverability/maintainability.

If people are looking for a specific import, or a key in an array (in PHP) or property of an object (both PHP and JS), or importing from a specific package/file path, or a name in a list of things, or a attribute/prop of an HTML/JSX tag, … having these things sorted (and I do propose alphabetical here), makes finding/ensuring something so. much. easier. … No?

How long does it take you to see if the SelectControl component is already available in the following code? What about the onClick prop?

import _isEmpty from 'lodash/isEmpty';
import { withSelect, subscribe, withDispatch, select } from '@wordpress/data';
import { ToggleControl, SelectControl, RichText } from '@wordpress/components';
import { apiFetch } from '@wordpress/api-fetch';

function render() {
    return (
        <Button class="button click" onBlur={ onClick } onClick={ () => onClick( true ) } id="click" />

How about now?

import _isEmpty from 'lodash/isEmpty';

import { apiFetch } from '@wordpress/api-fetch';
import { RichText, SelectControl, ToggleControl } from '@wordpress/components';
import { select, subscribe, withDispatch, withSelect } from '@wordpress/data';

function render() {
    return (
            class="button click"
            onBlur={ onClick }
            onClick={ () => onClick( true ) }

Is “Banana” in the following list of healthy fruit? How quickly can you tell?

  • Apple
  • Blueberry
  • Orange
  • Dragon Fruit
  • Mango
  • Banana
  • Avocado
  • Lychee

When Not to Sort (Alphabetically)

There are definitely (a lot of) reasons one should not sort things (alphabetically), for example, if a specific order is required, or if things should be listed chronologically (e.g., “Most Recent Projects Doing Whatever”, in contrast to a list of “Projects Doing Whatever” where the order is not important, so one can decide to list the projects by name in an alphabetical fashion). Also if there are better ways to sort/structure things, for example, putting the key prop on a JSX tag first.

These are not the situations I mean. I am more talking about things where there is no order, and where adding some does not negatively affect anything at all.

What Do You Think?

I am genuinely interested in whether or not you sort stuff yourself and/or would like other people to do that too, or if not. And why? Is it for the same reasons that I mentioned? Do you see other/better benefits? Do you disagree with anything I mentioned?

What kinds of things would you like to see sorted alphabetical, which ones you don’t care, and what should not be alphabetized? For what reasons?

Please leave a comment. Thanks!
(And no, you don’t have to do that in alphabetical manner and wait for your first name’s first letter to be on. 😉)

Leave a Reply

Your email address will not be published. Required fields are marked *