The dissertation deals with the proposal of methodology and creation of a mathematical model for the timber sorting facility. The mathematical model has been created based on the knowledge of the field of sorting timber. The mathematical model was created through the matrix relationship of the measured values to the sets of parameter criteria. The functionality of the mathematical model was tested by sorting data from databases of three sawing diagrams. Sawing diagrams were designed to represent different classifications in practice. Sorting parameters were the dimensions of the timber (thickness, width and length), and the quality of timber indicated by the bending strength for the spruce. Two mathematical methods were used to validate and optimize the mathematical model: Single-linking clustering, Centroids clustering and Ward's method, and K-means. Excel and IBM SPSS were used to process and produce results.