def assign_occupancy(self):
        """
        For each point of the grid, total occupancy and contribution factor are computed and saved.
        The grid is then ordered with decreasing value of occupancy.
        The fourth column of the array correspond to the occupancy of the point and the fifth to 
        the contribution for this point.

        :return sortedgrid: 2d-array, coordinates of each point of the grid
        """
        grid = self.grid
        nbknots = grid.shape[0]
        grid = numpy.append(grid, numpy.zeros((nbknots, 1), dtype="float"), axis=1)

        for i in range(nbknots):
            occ, contrib = self.calc_occupancy(grid[i, 0:3])
            grid[i, 3] = occ
            grid[i, 4] = contrib

        order = numpy.argsort(grid, axis=0)[:, -2]
        sortedgrid = numpy.empty_like(grid)
        for i in range(nbknots):
            sortedgrid[nbknots - i - 1, :] = grid[order[i], :]

        return sortedgrid