A microfluidic apparatus having a one-dimensional or two-dimensional hydrodynamic flow system to control stable and proper digitally coded bead orientation through the optical detection area of a bioanalysis system. The hydrodynamic system include one core flow, which carries the rectangular barcode beads, and sheath flows, on the sides of or about or around the outer periphery of the core flow, pull the core flow into a proper orientation. The sheath flows, at much higher flow speed but lower volume flow rate, can be pushed or pulled by vacuum, gravity, or pressure. By this method, the coded bead will align themselves in line and flow reliably, without wobbling or flipping, in the core flow channel through the detection zone. By adjusting the relative flow rate of core flow and sheath flows, the coded beads flow reliably in the flow system, thus it can be decoded and detected by an optical system accurately.