finding correct directories

I have directories like V00R01,V00R02,V01R01,V01R02 in a directory
where V is version and R is a release. basically I need to set base directory and current directory. Under a version there can be any number of releases and there can be number of versions also.
V00R01...V00R50..so on
also,
V00R01...V00R50.. V01R01..V01R50 ...

Case 1: V00R30 and V00R31, V00R32.. in this case.. i have to set base to V00R31 and current to V00R32. (latest directory as current and previous one as base)

Case 2: There can be more versions .. like V00R30, V00R31, V00R32 and
V01R01, V01R02,V01R03.. then in this case.. i need to set base to V00R32 and Current directory to V01R03. (here also latest of V01 to current and latest of V00 to base)

A possible solution :

eval $(
   ls -rd V??R?? | \
   awk '
   NR==1 { 
      current = $1; 
      base    = "";
      cversion = substr($1, 2, 2);
      next
   }
   { 
      version = substr($1, 2, 2);
      if (version == cversion) {
         if (base == "") base = $1;
      } else  {
         base = $1;
         exit;
     }
   }
   END {
      print "current=" current;
      print    "base=" base;
   }
   '
)

echo "Current = $current"
echo "Base    = $base"

Directories list:

$ ls -d V??R??
V00R00  V00R01  V00R11  V00R12  V01R00  V01R01  V02R00  V02R01  V02R03

Output:

Current = V02R03
Base    = V01R01

Jean-Pierre.

set -- V*R*
shift $(( $# - 2 ))
base=$1
current=$2
set -- V00R*
shift $(( $# - 1 ))
base=$1
set -- V01R*
shift $(( $# - 1 ))
current=$1