Supersort - Sort multiple variables together
Managed to do this by putting it all into an array:

{% set productID = [] %}
{% set orders = craft.orders().limit(null).all() %}

{% for order in orders %}
    {% for item in order.lineItems %}
        {% set productID = productID |merge([ {
            'productId' : item.purchasable.product.customProductId,
            'groupName' : order.groupName
        }]) %}
    {% endfor %}
{% endfor %}

{% set productID = productID | supersort('sortAs', '{{ object.productId }} {{ object.groupName }}') %}

{% for theID in productID %}
    {{ theID.groupName }} - {{ theID.productId }}
{% endfor %}