A direct and systematic algorithm is proposed to find one-dimensional optimal system for the group invariant solutions, which is attributed to the classification of its corresponding one-dimensional Lie algebra. Since the method is based on different values of all the invariants, the process itself can both guarantee the comprehensiveness and demonstrate the inequivalence of the optimal system, with no further proof. To illustrate our method more clearly , we give a couple of well-known examples: the Korteweg-de Vries (KdV) equation and the heat equation.