A method for sorting a plurality of metal alloy pieces into at least a first sorted collection of metal alloy pieces having a first metal alloy composition and a second sorted collection of metal alloy pieces having a second metal alloy composition different from the first metal alloy composition, the method comprising: conveying the plurality of metal alloy pieces on a conveyor belt at a predetermined speed; determining an approximate length of each of the plurality of metal alloy pieces along a line substantially parallel to a direction of travel of the conveyor belt, wherein the determining the approximate length of each of the plurality of metal alloy pieces comprises measuring the approximate length of each of the plurality of metal alloy pieces as they travel at a predetermined speed past a distance measuring device, wherein the distance measuring device utilizes a light source to determine the approximate length of each of the plurality of metal alloy pieces; exposing the plurality of metal alloy pieces to x-rays emitted by an x-ray source of an x-ray fluorescence, XRF, system, and detecting, by the XRF system, x-ray fluorescence signals emitted by the plurality of metal alloy pieces in response to the x-rays emitted by the x-ray source; wherein the XRF system is configured to measure an XRF spectrum emitted from a particular one of each of the plurality of metal alloy pieces only for a time period determined as a function of the measured approximate length for the particular one of each of the plurality of metal alloy pieces, wherein the time period is determined as a function of the measured approximate length of the particular one of each of the plurality of metal alloy pieces and the predetermined speed so that only the XRF spectrum emitted from the particular one of each of the plurality of metal alloy pieces is measured and not from an environment surrounding the particular one of each of the plurality of metal alloy pieces; classifying a first one of the plurality of metal alloy pieces as having the first metal alloy composition and classifying a second one of the plurality of metal alloy pieces as having the second metal alloy composition, wherein metal alloy compositions of the plurality of metal alloy pieces are classified as a result of acquired x-ray fluorescence detected from each of the plurality of metal alloy pieces using the XRF system; and sorting the first one of the plurality of metal alloy pieces from the second one of the metal alloy pieces in response to classifying the first one of the plurality of metal alloy pieces as having the first metal alloy composition, and classifying the second one of the plurality of metal alloy pieces as having the second metal alloy composition. conveying the plurality of metal alloy pieces on a conveyor belt at a predetermined speed; determining an approximate length of each of the plurality of metal alloy pieces along a line substantially parallel to a direction of travel of the conveyor belt, wherein the determining the approximate length of each of the plurality of metal alloy pieces comprises measuring the approximate length of each of the plurality of metal alloy pieces as they travel at a predetermined speed past a distance measuring device, wherein the distance measuring device utilizes a light source to determine the approximate length of each of the plurality of metal alloy pieces; exposing the plurality of metal alloy pieces to x-rays emitted by an x-ray source of an x-ray fluorescence, XRF, system, and detecting, by the XRF system, x-ray fluorescence signals emitted by the plurality of metal alloy pieces in response to the x-rays emitted by the x-ray source; wherein the XRF system is configured to measure an XRF spectrum emitted from a particular one of each of the plurality of metal alloy pieces only for a time period determined as a function of the measured approximate length for the particular one of each of the plurality of metal alloy pieces, wherein the time period is determined as a function of the measured approximate length of the particular one of each of the plurality of metal alloy pieces and the predetermined speed so that only the XRF spectrum emitted from the particular one of each of the plurality of metal alloy pieces is measured and not from an environment surrounding the particular one of each of the plurality of metal alloy pieces; classifying a first one of the plurality of metal alloy pieces as having the first metal alloy composition and classifying a second one of the plurality of metal alloy pieces as having the second metal alloy composition, wherein metal alloy compositions of the plurality of metal alloy pieces are classified as a result of acquired x-ray fluorescence detected from each of the plurality of metal alloy pieces using the XRF system; and sorting the first one of the plurality of metal alloy pieces from the second one of the metal alloy pieces in response to classifying the first one of the plurality of metal alloy pieces as having the first metal alloy composition, and classifying the second one of the plurality of metal alloy pieces as having the second metal alloy composition.