DataTables - Sort duration

HTML

<link rel="stylesheet" href="https://cdn.datatables.net/r/dt/dt-1.10.9/datatables.min.css">
<script src="https://cdn.datatables.net/r/dt/dt-1.10.9/datatables.min.js"></script>
<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Duration</th>
        </tr>
    </thead>
</table>

JavaScript

jQuery.extend(jQuery.fn.dataTableExt.oSort, {
    "duration-pre": function (s) {        
        var duration;
        
        s = s.toLowerCase();
        
        if(s === 'n/a'){ 
            duration = -1;
            
        } else {            
            d = s.match(/(?:(\d+)m)?\s*(?:(\d+)s)?/);
            duration = parseInt(d[1] ? d[1] : 0) * 60 + parseInt(d[2] ? d[2] : 0);
        }
        
        return duration;
    }
});

$(document).ready(function (){
    var table = $('#example').DataTable({
       data: [
           ['1m 1s'],
           ['2m 45s'],
           ['10m 45s'],
           ['45s'],
           ['1m'],
           ['N/A']
       ],
       columns: [
           { type: 'duration' }
       ]
    });
});