# Buggy code
def get_implementations(self, *types, **kwargs):
    """
    Get all mixin implementations that implement *all* of the provided ``types``.

    Arguments:
        types (one or more type): The types a mixin implementation needs to implement in order to be returned.

    Returns:
        list: A list of all found implementations
    """

    sorting_context = kwargs.get("sorting_context", None)

    result = None

    for t in types:
        implementations = self.plugin_implementations_by_type[t]
        if result is None:
            result = set(implementations)
        else:
            result = result.intersection(implementations)

    if result is None:
        return []

    def sort_func(impl):
        sorting_value = None
        if sorting_context is not None and isinstance(impl[1], SortablePlugin):
            try:
                sorting_value = impl[1].get_sorting_key(sorting_context)
            except Exception:
                self.logger.exception(
                    "Error while trying to retrieve sorting order for plugin {}".format(
                        impl[0]
                    )
                )

            if sorting_value is not None:
                try:
                    sorting_value = int(sorting_value)
                except ValueError:
                    self.logger.warning(
                        "The order value returned by {} for sorting context {} is not a valid integer, ignoring it".format(
                            impl[0], sorting_context
                        )
                    )
                    sorting_value = None

        plugin_info = self.get_plugin_info(impl[0], require_enabled=False)
        return (
            sorting_value is None,
            sorting_value,
            not plugin_info.bundled if plugin_info else True,
            impl[0],
        )

    return [impl[1] for impl in sorted(result, key=sort_func)]


# Traceback (TypeError)
2019-10-08 14:14:51,399 - octoprint.server.preemptive_cache - INFO - Preemptively caching / (ui _default) for {'base_url': 'http://192.168.0.113:5000/', 'path': '/', 'query_string': 'l10n=en'}
[2019-10-08 14:14:51,556] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\octoprint\venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 181, in index
fetch_template_data(refresh=force_refresh)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 755, in fetch_template_data
sorted_missing = sorted(missing_in_order, key=key_func)
TypeError: '<' not supported between instances of 'str' and 'NoneType'
[2019-10-08 14:14:51,743] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\octoprint\venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 181, in index
fetch_template_data(refresh=force_refresh)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 755, in fetch_template_data
sorted_missing = sorted(missing_in_order, key=key_func)
TypeError: '<' not supported between instances of 'str' and 'NoneType'
[2019-10-08 14:14:51,884] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\octoprint\venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\octoprint\venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 181, in index
fetch_template_data(refresh=force_refresh)
File "c:\octoprint\venv\lib\site-packages\octoprint\server\views.py", line 755, in fetch_template_data
sorted_missing = sorted(missing_in_order, key=key_func)
TypeError: '<' not supported between instances of 'str' and 'NoneType'

# Fixed code
def get_implementations(self, *types, **kwargs):
    """
    Get all mixin implementations that implement *all* of the provided ``types``.

    Arguments:
        types (one or more type): The types a mixin implementation needs to implement in order to be returned.

    Returns:
        list: A list of all found implementations
    """

    sorting_context = kwargs.get("sorting_context", None)

    result = None

    for t in types:
        implementations = self.plugin_implementations_by_type[t]
        if result is None:
            result = set(implementations)
        else:
            result = result.intersection(implementations)

    if result is None:
        return []

    def sort_func(impl):
        sorting_value = None
        if sorting_context is not None and isinstance(impl[1], SortablePlugin):
            try:
                sorting_value = impl[1].get_sorting_key(sorting_context)
            except Exception:
                self.logger.exception(
                    "Error while trying to retrieve sorting order for plugin {}".format(
                        impl[0]
                    )
                )

            if sorting_value is not None:
                try:
                    sorting_value = int(sorting_value)
                except ValueError:
                    self.logger.warning(
                        "The order value returned by {} for sorting context {} is not a valid integer, ignoring it".format(
                            impl[0], sorting_context
                        )
                    )
                    sorting_value = None

        plugin_info = self.get_plugin_info(impl[0], require_enabled=False)
        return (
            sorting_value is None,
            sv(sorting_value),
            not plugin_info.bundled if plugin_info else True,
            sv(impl[0]),
        )

    return [impl[1] for impl in sorted(result, key=sort_func)]