JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

JavaScript

var arry = [{
    'name': '2.1 Foo',
    'children': [{
        'name': '2.1.1 Foo ',
      },
      {
        'name': '2.1.3 Foo ',
      },
      {
        'name': '2.1.10 Foo ',
      },
      {
        'name': '2.1.2 Foo ',
      },
    ],
  },
  {
    'name': '1.1 Foo',
    'children': [{
        'name': '1.1.2 Foo ',
      },
    ],
  },
];



function SortByName(a, b){
	    if(a.children){
  	        a.children = a.children.sort(SortByName)
        }
        if(b.children){
  	        b.children = b.children.sort(SortByName)
        }
        var aName = a.name.toLowerCase();
        var bName = b.name.toLowerCase();

        return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
    }
    
    
    $(document).ready(function() {
  var sorted_array = arry.sort(SortByName)
  console.log(sorted_array)
})