Sorts the inputted items by their natural order, trying to extract a \
    number from them to sort by.
    
    :param      a       <str>
                b       <str>
    
    :return     <int> 1 || 0 || -1
    
    :usage      |>>> from projex import sorting
                |>>> a = [ 'test-1.1.2', 'test-1.02', 'test-1.2', 'test-1.18' ]
                |>>> a.sort()
                |>>> print a
                |['test-1.02', 'test-1.1.2', 'test-1.18', 'test-1.2']
                |>>> a.sort( sorting.natural )
                |>>> print a
                |['test-1.1.2', 'test-1.02', 'test-1.2', 'test-1.18']
                |>>> a.sort( sorting.versional )
                |>>> print a
                |['test-1.1.2', 'test-1.02', 'test-1.18', 'test-1.2']

def versional(a, b):
    """
    Sorts the inputted items by their natural order, trying to extract a \
    number from them to sort by.
    
    :param      a       <str>
                b       <str>
    
    :return     <int> 1 || 0 || -1
    
    :usage      |>>> from projex import sorting
                |>>> a = [ 'test-1.1.2', 'test-1.02', 'test-1.2', 'test-1.18' ]
                |>>> a.sort()
                |>>> print a
                |['test-1.02', 'test-1.1.2', 'test-1.18', 'test-1.2']
                |>>> a.sort( sorting.natural )
                |>>> print a
                |['test-1.1.2', 'test-1.02', 'test-1.2', 'test-1.18']
                |>>> a.sort( sorting.versional )
                |>>> print a
                |['test-1.1.2', 'test-1.02', 'test-1.18', 'test-1.2']
    """
    stra = nstr(a).lower()
    strb = nstr(b).lower()

    # look up all the pairs of items
    aresults = EXPR_VERSIONAL.findall(stra)
    bresults = EXPR_VERSIONAL.findall(strb)

    # make sure we have the same number of results
    bcount = len(bresults)
    for i in range(len(aresults)):
        # make sure we don't exceed the number of elements in b
        if bcount <= i:
            break

        atext, anum = aresults[i]
        btext, bnum = bresults[i]

        # compare the text components
        if atext != btext:
            return cmp(atext, btext)

        if not anum:
            anum = 0
        if not bnum:
            bnum = 0

        # compare the numeric components
        if atext == '.':
            anum = int(float('.' + anum) * 10000)
            bnum = int(float('.' + bnum) * 10000)
        else:
            anum = int(anum)
            bnum = int(bnum)

        if anum != bnum:
            return cmp(anum, bnum)

    # b has less characters than a, so should sort before
    return 1