Dynamic ORDER BY clause in PL/SQL cursor I am not sure if this is simply impossible or if I need to approach this from a different angle.

Simplified, here is what I am trying:

create or replace FUNCTION someFunction(SortCol1 varchar2 default 'column1',
                                        SortDir1 varchar2 default 'ASC')
RETURN STUFF pipelined
AS
CURSOR c1 is
    SELECT
        *
    FROM
        table1
    ORDER BY
        SortCol1 SortDir1;

BEGIN
    FOR c1_rec IN c1
    LOOP
        -- Some logic, etc...
    END LOOP;
END someFunction;


Upon compiling this simply tells me that my SQL is improperly terminated. It does not like the SortCol1 SortDir1
You can't dynamically change the column you're sorting by using static SQL.  You'd need to use dynamic SQL.  Something like this should work

create or replace FUNCTION someFunction(SortCol1 varchar2 default 'column1',
                                        SortDir1 varchar2 default 'ASC')
RETURN STUFF pipelined
AS
    c1 SYS_REFCURSOR;
    c1_rec table1%rowtype;
BEGIN
    OPEN c1
     FOR 'select * from table1 order by ' || sortCol1 || ' ' || sortDir1;

    LOOP
        FETCH c1 INTO c1_rec;  

        &lt;&lt;do something&gt;&gt;
    END LOOP;

END someFunction;