Let $$J_1>J_2>\dots $$
J
1
>
J
2
>
⋯
be the ranked jumps of a gamma process $$\tau _{\alpha }$$
τ
α
on the time interval $$[0,\alpha ]$$
[
0
,
α
]
, such that $$\tau _{\alpha }=\sum _{k=1}^{\infty }J_k$$
τ
α
=
∑
k
=
1
∞
J
k
. In this paper, we design an algorithm that samples from the random vector $$(J_1, \dots , J_N, \sum _{k=N+1}^{\infty }J_k)$$
(
J
1
,
⋯
,
J
N
,
∑
k
=
N
+
1
∞
J
k
)
. Our algorithm provides an analog to the well-established inverse Lévy measure (ILM) algorithm by replacing the numerical inversion of exponential integral with an acceptance-rejection step. This research is motivated by the construction of Dirichlet process prior in Bayesian nonparametric statistics. The prior assigns weight to each atom according to a GEM distribution, and the simulation algorithm enables us to sample from the N largest random weights of the prior. Then we extend the simulation algorithm to a generalised gamma process. The simulation problem of inhomogeneous processes will also be considered. Numerical implementations are provided to illustrate the effectiveness of our algorithms.