Please help me to understand the logic written in the ORDER BY clause of the SQL query below. what it means by writing the CASE condition.

```
SELECT ROW_NUMBER() OVER(Order by internalSampleCode) as RowC, internalSampleCode,
CONVERT(NVARCHAR(1000), SP.notes) AS Treatment,
CONVERT(NVARCHAR(1000), SP.sampleDescription) AS Matrix,
CONVERT(NVARCHAR(1000), SP.remarks) AS SamplingInstructions,
samplePartnerCode AS eSMSampleCode,
A.activityCode AS Activity
FROM SamplesPartners AS SP
LEFT JOIN ActivitiesSamplesPartners ASP ON SP.samplePartnerIncId = ASP.samplePartnerIncId
AND SP.samplePartnerSqlId = ASP.samplePartnerSqlId
AND SP.isDeleted = 0
AND ASP.isDeleted = 0
LEFT JOIN Activities A ON A.activityIncId = ASP.activityIncId
AND A.activitySqlId = ASP.activitySqlId
AND A.isDeleted = 0
WHERE SP.samplePartnerCode IN (@specimencode)
ORDER BY (CASE WHEN A.activityCode IS NULL THEN 1 ELSE 0 END), A.activityCode,
(CASE WHEN CONVERT(NVARCHAR(1000), SP.notes) IS NULL THEN 1 ELSE 0 END), CONVERT(NVARCHAR(1000), SP.notes),
(CASE WHEN CONVERT(NVARCHAR(1000), SP.sampleDescription) IS NULL THEN 1 ELSE 0 END), CONVERT(NVARCHAR(1000), SP.sampleDescription)
```