Imperative Sentences in Direct Speech are used to demonstrate Request, Order, Command, etc. Imperative Sentences in Direct Speech begin with Principal verbs like Go, Make, etc.
The reporting verbs like "begged", "beg", etc. in indirect speech are changed into "said", "say", etc. in direct speech.
"To" is used before the Principal Verbs in Indirect Speech.
Thus, going by the options is one of the best techniques to solve these questions.
For example:
John ordered his assistant to bring him a glass of water. (Indirect Speech)
John said to his assistant, "Bring me a glass of water." (Direct Speech)
The following things in the sentence will change when changed from Indirect Speech to Direct Speech:
To convert the reported speech into direct speech, the verb "ordered" becomes "told" in reporting, and the command remains unchanged in quotation marks. The pronoun "those" refers to specific riots, so in direct speech, it becomes "these" for immediacy.
Therefore, the correct answer is: "The District Magistrate told the police, 'Work all night and put an end to these riots.'"
Therefore, option 3 is correct.