Zip filter in the right order

Zip filter in the right order

Hello,
I have a little problem, I hope you can help me.

I would like to have a postcode filter, which displays the entries that were entered in the correct order as entered in the input field.

e.g. My input
011

output:
01129
10117
10117

The first is correct. The other two are wrong.

  1. function looseCharacterMatch(a, b) {a = a.split("");
      b = b.substring(0,a.length);
      var c = true;
      for (var i = 0; i < a.length; i++) {
        if (b.replace(a[i], "") == b) {
          c = false;
        }
        b = b.replace(a[i], "");
      }
      return c;
    }
    
    $("#plz").on("keyup", function () {
      var value = $(this).val().toLowerCase();
    
      $("#list").children().each(function () {
        var text = $(this).text().toLowerCase();
        $(this)[!looseCharacterMatch(value,text) ? 'hide':'show']();
      });
    });
And the HTML code

  1.     <div class="title-plz"><input id="plz" type="search" placeholder="PLZ"></div>

        <ul id="list">
        <li><a href="#/01129/">01129</a></li>
        <li><a href="#/01307/">01307</a></li>
        <li><a href="#/01814/">01814</a></li>
        <li><a href="#/10117/">10117</a></li>
        <li><a href="#/10117/">10117</a></li>
        </ul>
I hope someone can help me.

Many Thanks.
Sorry for my bad english.