Dynamic ORDER BY clause in PL/SQL cursor
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;