JSFiddle - React, Tailwind, and code Playground

JavaScript

console.log(["foo4", "bar6", "nam12", "bing10", "dan9", "wut1"]    .sort(function (a, b) {
        return +a.split(/(\d+)/)[1] - +b.split(/(\d+)/)[1];
    }));