Excellent thinking! Because B dissolves better than A, more of B moves up, as compared to A. In this manner, A and B get separated as A doesn't move, but, B moves. This method of separation is called chromatography
There are hundreds of other methods of separating mixtures. We have only seen a few examples. Whatever the method, the concept remains the same: find a property that is different for the two components of the mixture, and use this difference in properties to separate them. The property can be boiling point, density, size of particles, how much they dissolve in water, etc.