Plural pieces of data where N (N>;2) elements are arranged in a predetermined-direction in a specific-order are sorted into any one of N labels using a graph-cut-process. Each of the plural pieces of data has scores indicating element-likenesses for the plural respective elements. For each piece of data, weights are set about links along a first-direction directing from a node s to a node t so that a small weight is given to a link corresponding to an element having a maximum-score in the data. A weight for regulating cutting is set about links along a second-direction opposite to the first-direction and links along a direction in which the order of the respective pieces of data progresses. A graph-cut-process is executed on a graph for which the weights are set to determine links to be cut, and the N labels are allocated to the plural pieces of data.