Custom Column - Example custom sort

Answer to Sorting files by filename part.
Creates the columns Col1, Col2, and Col3. Allows independent sorting of each numeric part of the filename.

function OnInit(initData)
{
  initData.name = "MultiColSort";
  initData.desc = "Add sortable columns for numeric parts";
  initData.copyright = "";
  initData.version = "1.0";
  initData.default_enable = false;

  var col = initData.AddColumn();
  col.name = "Col1";
  col.method = "OnCol1";
  col.label = "Col1";
  col.justify = "left";
  col.autogroup = false;
  col.autorefresh=true;

  col = initData.AddColumn();
  col.name = "Col2";
  col.method = "OnCol2";
  col.label = "Col2";
  col.justify = "left";
  col.autogroup = false;
  col.autorefresh=true;

  col = initData.AddColumn();
  col.name = "Col3";
  col.method = "OnCol3";
  col.label = "Col3";
  col.justify = "left";
  col.autogroup = false;
  col.autorefresh=true;
}

function ColCommon(colnumber,scriptColData)
{
  if (scriptColData.item.is_dir) {
    scriptColData.value = "";
    scriptColData.sort = 3;
  } else{
    var re=/^.+_(\d+)_(\d+)_(\d+)/i;
    if (re.exec(scriptColData.item.name)){
      switch (colnumber){
        case 1: scriptColData.value = RegExp.$1;break;
        case 2: scriptColData.value = RegExp.$2;break;
        case 3: scriptColData.value = RegExp.$3;break;
      }
    } else{
      scriptColData.value = "";
    }
  }
}

// Implement the OnCol1 column
function OnCol1(scriptColData)
{
  if (scriptColData.col!="Col1") return;
  ColCommon(1,scriptColData);
}
// Implement the OnCol2 column
function OnCol2(scriptColData)
{
  if (scriptColData.col!="Col2") return;
  ColCommon(2,scriptColData);
}

// Implement the OnCol3 column
function OnCol3(scriptColData)
{
  if (scriptColData.col!="Col3") return;
  ColCommon(3,scriptColData);
}