r'''
    Return a list of full path of files matching 'models', sorted in human
    numerical order (i.e., 0 1 2 ..., 10 11 12, ..., 100, ..., 1000).

    Files are supposed to be named identically except one variable component
    e.g. the list,
      test.weights.e5.lstm1200.ldc93s1.pb
      test.weights.e5.lstm1000.ldc93s1.pb
      test.weights.e5.lstm800.ldc93s1.pb
    gets sorted:
      test.weights.e5.lstm800.ldc93s1.pb
      test.weights.e5.lstm1000.ldc93s1.pb
      test.weights.e5.lstm1200.ldc93s1.pb

def all_files(models=[]):
    r'''
    Return a list of full path of files matching 'models', sorted in human
    numerical order (i.e., 0 1 2 ..., 10 11 12, ..., 100, ..., 1000).

    Files are supposed to be named identically except one variable component
    e.g. the list,
      test.weights.e5.lstm1200.ldc93s1.pb
      test.weights.e5.lstm1000.ldc93s1.pb
      test.weights.e5.lstm800.ldc93s1.pb
    gets sorted:
      test.weights.e5.lstm800.ldc93s1.pb
      test.weights.e5.lstm1000.ldc93s1.pb
      test.weights.e5.lstm1200.ldc93s1.pb
    '''

    def nsort(a, b):
        fa = os.path.basename(a).split('.')
        fb = os.path.basename(b).split('.')
        elements_to_remove = []

        assert len(fa) == len(fb)

        for i in range(0, len(fa)):
            if fa[i] == fb[i]:
                elements_to_remove.append(fa[i])

        for e in elements_to_remove:
            fa.remove(e)
            fb.remove(e)

        assert len(fa) == len(fb)
        assert len(fa) == 1

        fa = keep_only_digits(fa[0])
        fb = keep_only_digits(fb[0])

        if fa < fb:
            return -1
        if fa == fb:
            return 0
        if fa > fb:
            return 1

    base = list(map(lambda x: os.path.abspath(x), maybe_inspect_zip(models)))
    base.sort(cmp=nsort)

    return base