As a LabVIEW vi programmer we know that working in the LabVIEW platform to solve a particular problem is far more easier than other environments due to its graphical flow based programming and extensive collection of libraries and examples for almost every type of problems.
There is a module in NI for image processing “The Vision Development Module” which is for developing and deploying machine vision applications according to the project requirement. It includes hundreds of functions to process images by enhancing them, checking for presence, locating features, identifying objects (this particular thing might be the master key in your case), and measuring parts.
The best thing about LabVIEW programming is that you make a copy of the particular examples which are the most suitable for your project and customize your own programs with the necessary blocks used in those examples.
Now for your requirement here are the two links of ni which might be helpful for your project:
Most importantly you need to develop your sorting methodology on your own and use it with the image processing/pattern recognition part of the project.
Additional info: Along with programming libraries, the NI Vision Development Module also includes NI Vision Assistant . Vision Assistant is a tool for prototyping and testing image processing applications. To prototype an image processing application, build custom algorithms with the Vision Assistant scripting feature. The scripting feature records every step of the processing algorithm. After completing the algorithm, you can test it on other images to make sure it works. (http://www.ni.com/example/6712/en/)