Metal ion separations using electrically switched ion exchange