(a) Except as otherwise provided in subsection (d) of this section, no gift, devise, or endowment for religious, educational, charitable, or benevolent purposes, which in other respects is valid under the laws of this state, shall be invalid or fail by reason of the indefiniteness or uncertainty of the recipient of the gift, devise, or endowment or by reason that it is or has become unlawful, impracticable, impossible to achieve, or wasteful.
(b) The court, on application of any interested person or the Attorney General may determine and order an administration or distribution of the gift, devise, or endowment in a manner as consistent as possible with the intent expressed in the document creating the gift, devise, or endowment. This section shall not be deemed to limit application of the common law doctrines of cy pres and deviation or of section 58-615.
(c) In an application for relief under this section which is not brought by the Attorney General, notice of the proceeding shall be given to the Attorney General as a representative for the charitable interests involved.
(d) Subsection (a) of this section shall not apply if the document creating the gift, devise, or endowment expressly provides for an alternate disposition of the gift, devise, or endowment in the event the gift, devise, or endowment has become unlawful, impracticable, impossible to achieve, or wasteful. A general residuary devise by will shall not be considered an express provision for an alternate disposition.
(e) Any gift, devise, or endowment to a trust with charitable purposes as described in section 30-3831 shall be governed by section 30-3839.