Sorting layer is a property of SpriteRenderer, it's used to specify which object is at top, and which object is at bottom.
If you want to change the sorting layer in script, you can use following code:
SpriteRenderer sprite = GetComponent<SpriteRenderer>();
sprite_renderer.sortingOrder = ..;
sprite_renderer.sortingLayerName = ..;