Again assuming the dataframe is named df, run str(df[1, ]) to confirm that target is a factor and not a column of strings. If it is a factor, run levels(df$target) to see the order in which the levels are specified. Either you did not enter it as a factor or you did not specify an order of levels.
Please consider to use StatSteph´s provided code. This is better coding practice, because it firstly uses the dplyr- independent pipe (|> instead of %>%) and furthermore it seperates the commands arrange and mutate, which is good if you collaborate with others or want to change something in your code.
I cant confirm that it is necessary to turn the ID column into numeric. If it is not numeric in the first place, but you need it to be numeric (id´s mostly also have to be factorial as they are not continuous but discrete) your code is generally correct. However I would always recommend to not mix your commands. In your code you again transform a variable inside the arrange command. Better do so before in the mutate command as well, it would look like this then:
df |>
mutate(target=factor(target, levels = c("POU5F1", "NANOG", "SOX2" , "DNMT3B")),
SG_ID = as.numeric(SG_ID)) |>
arrange(SG_ID, sample, target) # include sample before target and after id so it gets arranged by id, sample and within the sample groups by target
Please run this and let me know if it is not in your prefered structure now.
Another hint for future posts: please provide code within code chunk marks " ```{r} # your code" followed by another three "`"