def get_custom_sorted_colors(colors):
    """Return a list of custom-sorted colors from given one.

    A custom algorithm (though I prefer using the word
    "recipe" here) is used based on what we believe to
    be a good way of organizing a somewhat large list of
    colors.

    Parameters
    ==========

    colors (list of colors)
        colors are sequence of integers; such integers
        are in the range(256) and represent the values
        of the red, green and blue channel of a color;

        a fourth integer may also be present, representing
        the value for the color's alpha channel, but we
        don't consider it to be relevant for our sorting
        operation, so it is not taken into account.

    Alternative implementation
    ==========================

    Just thought it would be interesting to mention that
    this function could also be implemented as a
    function to use as the key of list.sort or the
    "sorted" built-in function, instead of returning
    a new list as we in this function.

    However I think presenting the steps as done in this
    function makes it easier to understand and maintain
    this function.

    Nonetheless, the alternative implementation is not only
    interesting, but it also takes only 60% (roughly) of
    the time the current implementation takes to sort the
    colors (maybe cause the current implementation creates
    a new list). The alternative implementation can be
    found below just after the definition of this function,
    commented out.
    """
    ### separate the colors into those which have no
    ### saturation and the ones which have

    no_sat_colors, colors_with_saturation = separate_by_condition(
        colors, get_saturation
    )

    ### sort the colors without saturation by their
    ### luma
    no_sat_colors.sort(key=sort_colors_by_luma)

    ### for the colors with saturation, create a dict
    ### which maps strings like 'red', 'orange', 'yellow',
    ### 'green', etc. (names of basic colors), to a set
    ### of hue values closer to such basic colors;
    ###
    ### for instance, the 'red' field will have a list
    ### of colors whose hues are closer to red;
    ###
    ### the dict is a collections.OrderedDict instance
    ### with items ordered according to how the hue
    ### naturally progresses from 0 to 359
    hue_name_to_colors = map_colors_by_hue(colors_with_saturation)

    ### we are only interested in the values of such
    ### dict (the lists of colors)
    color_lists = hue_name_to_colors.values()

    ### now, iterate over the lists sorting the colors
    ### of that list by luma
    for color_list in color_lists:
        color_list.sort(key=sort_colors_by_luma)

    ### then, concatenate all lists of colors and
    ### also the list of colors with no saturation
    ### into a single list of colors
    ###
    ### this list will have the colors in a logical
    ### and somewhat pleasing distribution: colors
    ### without saturation first, sorted by luma,
    ### then colors with saturation grouped by their
    ### hues and with each of those groups further
    ### sorted by luma
    colors = sum(color_lists, no_sat_colors)

    ### finally, return such list
    return colors
Return a list of custom-sorted colors from given one.

    A custom algorithm (though I prefer using the word
    "recipe" here) is used based on what we believe to
    be a good way of organizing a somewhat large list of
    colors.

    Parameters
    ==========

    colors (list of colors)
        colors are sequence of integers; such integers
        are in the range(256) and represent the values
        of the red, green and blue channel of a color;

        a fourth integer may also be present, representing
        the value for the color's alpha channel, but we
        don't consider it to be relevant for our sorting
        operation, so it is not taken into account.

    Alternative implementation
    ==========================

    Just thought it would be interesting to mention that
    this function could also be implemented as a
    function to use as the key of list.sort or the
    "sorted" built-in function, instead of returning
    a new list as we in this function.

    However I think presenting the steps as done in this
    function makes it easier to understand and maintain
    this function.

    Nonetheless, the alternative implementation is not only
    interesting, but it also takes only 60% (roughly) of
    the time the current implementation takes to sort the
    colors (maybe cause the current implementation creates
    a new list). The alternative implementation can be
    found below just after the definition of this function,
    commented out.
    
nodezator/ourstdlibs/color/custom.py