Stack the Christmas Gifts Someone has been hastily stacking the Christmas presents, and it's quite a mess:

           ========================
           |                      |
           ========================
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
        =======
        |     |
        |     |
        |     |
        =======
  ===================
  |                 |
  |                 |
  |                 |
  ===================
=================
|               |
|               |
|               |
|               |
=================
   =======
   |     |
   |     |
   =======


Like, seriously, how does that top present even balance. It's probably a hammer. To prevent this tower of presents from crumbling, you're to reorder the presents so they stack nicely:

        =======
        |     |
        |     |
        =======
        =======
        |     |
        |     |
        |     |
        =======
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
   =================
   |               |
   |               |
   |               |
   |               |
   =================
  ===================
  |                 |
  |                 |
  |                 |
  ===================
========================
|                      |
========================


The Rules


Each present consists of a top and bottom of = characters, and one or more middle rows, consisting of two | separated by spaces. The width of the present is the same in all its rows.
There are no empty lines.
Consecutive presents will overlap in at least one column.
Presents are to be stacked in order of decreasing width. In the event of a tie, the taller present should go below the flatter present.
Presents should be centred on the present beneath. If the present cannot be placed exactly in the centre (because the difference in widths is odd), you may choose either position that is half a character off the centre.
You may or may not assume that the input has a single trailing newline, but please state your assumption.
Your solution does not have to work for an empty input, but must be able to handle a single present.
You may write a program or function, which takes input via STDIN or function argument and returns the result or prints it to STDOUT.
This is code golf, so the shortest answer (in bytes) wins.
CJam, 81 70 bytes
'&quot;qN/{__Sm0=#&gt;}%N*&quot;=
=&quot;/&quot;=\&quot;\&quot;=&quot;*'&quot;++~]$_W='=/,f{1$'=/,m4/\N/\f{S*\N}}

So we have to stack the Christmas presents? This code does it like an actual person would do*.
First, we stack all the presents against a wall to easily move them up and down using this code:
'&quot;qN/{__Sm0=#&gt;}%N*

then, we identify each present as a separate item using this code:
&quot;=
=&quot;/&quot;=\&quot;\&quot;=&quot;*'&quot;++~]

then, we sort the presents based on their heights and widths using this code:
$

Till now, all the gifts have been stacked against a wall in order to have perfect alignment with each other. But as this is Christmas, we want to place the gifts aligned centered like a Christmas tree! This code does that:
_W=Af{1$Am4/\N/\f{S*\N}}

Here is a step by step output of the code for example in the question:
&quot;Step 1 - Stack the presents against a wall&quot;;
========================
|                      |
========================
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=======
|     |
|     |
|     |
=======
===================
|                 |
|                 |
|                 |
===================
=================
|               |
|               |
|               |
|               |
=================
=======
|     |
|     |
=======

&quot;Step 2 - Identify the presents as a collection of presents&quot;;
[&quot;========================
|                      |
========================&quot; &quot;=============
|           |
|           |
|           |
|           |
|           |
|           |
=============&quot; &quot;=======
|     |
|     |
|     |
=======&quot; &quot;===================
|                 |
|                 |
|                 |
===================&quot; &quot;=================
|               |
|               |
|               |
|               |
=================&quot; &quot;=======
|     |
|     |
=======&quot;]

&quot;Step 3 - Sort on height &amp; width, with presents stacked against a wall to help sort them&quot;;
=======
|     |
|     |
=======
=======
|     |
|     |
|     |
=======
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=================
|               |
|               |
|               |
|               |
=================
===================
|                 |
|                 |
|                 |
===================
========================
|                      |
========================

&quot;Final step - stack them like a Christmas Tree&quot;;
        =======
        |     |
        |     |
        =======
        =======
        |     |
        |     |
        |     |
        =======
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
   =================
   |               |
   |               |
   |               |
   |               |
   =================
  ===================
  |                 |
  |                 |
  |                 |
  ===================
========================
|                      |
========================

Try it online here
* Might differ from person to person though :P