Hierarchical magnetic assembly of nanowires