Context. The development of techniques for the inversion of sparse disk-integrated photometric data of asteroids is a very urgent task, due to the imminent commencements of large sky surveys from both space (Gaia) and the ground (Pan-STARRS). Aims. We developed a numerical algorithm for the inversion of sparse photometric data of asteroids. An application to real data collected in past by the Hipparcos satellite provided very encouraging results. Methods. The inversion method is based on the application of a "genetic" algorithm approach. The objects are assumed to have triaxial ellipsoid shape. However, it is shown by means of simulations and applications to real data that this simplistic choice does not cause any significant problems. The algorithm solves for a number of unknown parameters, including the spin period, the coordinates of the spin axis, the axial ratios of the ellipsoid, an initial rotational phase corresponding to the first observation of a given dataset, and the slope of a linear variation in the magnitude as a function of solar phase. Additional parameters, describing some possible albedo variegation of the surface, can also be introduced. Results. The application of the inversion technique to both simulations and a dataset of sparse photometric data obtained some years ago by the Hipparcos satellite shows that the performance of the algorithm is strongly encouraging, and the correct solution for the rotational parameters is obtained in the majority of cases when a reasonable number of observations are available.