Liquid Question: Sorting Metafields by Unit

Hello,

I am new to Liquid, however, I have been searching the docs, and I am still having some trouble.

What would the syntax look like for sorting metafields by their unit of measurement? I have the metafields I want to display in the namespace specs..

Here is the current liquid I have written:

{% if product_specs.size > 0 %}
  
    

      {% for spec in product.metafields.specs -%}
        - **{{ spec.first | capitalize }}**: {{ spec.last.value }}
      {%- endfor %}
    

  

{% endif %}

Here is the output:

Height: 55 mm
Weight: 2 oz
Width: 25 mm

So, I want Height and Width displayed next to each other, any thoughts or help on this would be greatly appreciated!