diff --git a/src/nf_modules/ucsc/main.nf b/src/nf_modules/ucsc/main.nf
index c63de6e227707552f5d51c3b0fc4cda34d9b8186..b4fe98dfac4378c00c828ee4119955d4e03fca83 100644
--- a/src/nf_modules/ucsc/main.nf
+++ b/src/nf_modules/ucsc/main.nf
@@ -18,7 +18,8 @@ process bedgraph_to_bigwig {
 # transform bed file of start-stop chromosome size to stop chromosome size
 awk -v OFS="\\t" '{print \$1, \$3}' ${bed} > chromsize.txt
 
-bedGraphToBigWig ${bg} \
+sort -T ./ -k1,1 -k2,2n ${bg} > \
+  bedGraphToBigWig - \
     chromsize.txt \
     ${bg.simpleName}_norm.bw
 """