I want to kill an entity that is nearest to the player. So I put the command:
So I was thinking, is it possible to reverse it to "kill a player that is nearest to an entity"?
to kill the entity that is the closest one to the player you can do
/execute @p ~ ~ ~ /kill @e[type=!player,c=1]
in reverse, to kill the player that is the closest to an entity, you can do
/execute @e[yourEntityHere] ~ ~ ~ /kill @p
be aware that
@p only selects the closest, non-dead player that matches the given criteria and can't be used to select entities.